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


PHP is_writable函数代码示例

本文整理汇总了PHP中is_writable函数的典型用法代码示例。如果您正苦于以下问题:PHP is_writable函数的具体用法?PHP is_writable怎么用?PHP is_writable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (is_null($this->dst) || "" === $this->dst) {
         return Result::error($this, 'You must specify a destination file with to() method.');
     }
     if (!$this->checkResources($this->files, 'file')) {
         return Result::error($this, 'Source files are missing!');
     }
     if (file_exists($this->dst) && !is_writable($this->dst)) {
         return Result::error($this, 'Destination already exists and cannot be overwritten.');
     }
     $dump = '';
     foreach ($this->files as $path) {
         foreach (glob($path) as $file) {
             $dump .= file_get_contents($file) . "\n";
         }
     }
     $this->printTaskInfo('Writing {destination}', ['destination' => $this->dst]);
     $dst = $this->dst . '.part';
     $write_result = file_put_contents($dst, $dump);
     if (false === $write_result) {
         @unlink($dst);
         return Result::error($this, 'File write failed.');
     }
     // Cannot be cross-volume; should always succeed.
     @rename($dst, $this->dst);
     return Result::success($this);
 }
开发者ID:greg-1-anderson,项目名称:Robo,代码行数:31,代码来源:Concat.php

示例2: __construct

 /**
  * Tests that the storage location is a directory and is writable.
  */
 public function __construct($filename)
 {
     // Get the directory name
     $directory = str_replace('\\', '/', realpath(pathinfo($filename, PATHINFO_DIRNAME))) . '/';
     // Set the filename from the real directory path
     $filename = $directory . basename($filename);
     // Make sure the cache directory is writable
     if (!is_dir($directory) or !is_writable($directory)) {
         throw new KoException('Cache: Directory :name is unwritable.', array(':name' => $directory));
     }
     // Make sure the cache database is writable
     if (is_file($filename) and !is_writable($filename)) {
         throw new KoException('Cache: File :name is unwritable.', array(':name' => $filename));
     }
     // Open up an instance of the database
     $this->db = new SQLiteDatabase($filename, '0666', $error);
     // Throw an exception if there's an error
     if (!empty($error)) {
         throw new KoException('Cache: Driver error - ' . sqlite_error_string($error));
     }
     $query = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'caches'";
     $tables = $this->db->query($query, SQLITE_BOTH, $error);
     // Throw an exception if there's an error
     if (!empty($error)) {
         throw new KoException('Cache: Driver error - ' . sqlite_error_string($error));
     }
     if ($tables->numRows() == 0) {
         // Issue a CREATE TABLE command
         $this->db->unbufferedQuery('CREATE TABLE caches(id VARCHAR(127) PRIMARY KEY, expiration INTEGER, cache TEXT);');
     }
 }
开发者ID:atlas1308,项目名称:testtesttestfarm,代码行数:34,代码来源:sqlite.php

示例3: initialize

 /**
  * {@inheritDoc}
  */
 public function initialize()
 {
     if (Filesystem::isLocalPath($this->url)) {
         $this->repoDir = $this->url;
     } else {
         $cacheDir = $this->config->get('cache-vcs-dir');
         $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
         $fs = new Filesystem();
         $fs->ensureDirectoryExists($cacheDir);
         if (!is_writable(dirname($this->repoDir))) {
             throw new \RuntimeException('Can not clone ' . $this->url . ' to access package information. The "' . $cacheDir . '" directory is not writable by the current user.');
         }
         // update the repo if it is a valid hg repository
         if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
             if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
                 $this->io->write('<error>Failed to update ' . $this->url . ', package information from this repository may be outdated (' . $this->process->getErrorOutput() . ')</error>');
             }
         } else {
             // clean up directory and do a fresh clone into it
             $fs->removeDirectory($this->repoDir);
             if (0 !== $this->process->execute(sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoDir)), $output, $cacheDir)) {
                 $output = $this->process->getErrorOutput();
                 if (0 !== $this->process->execute('hg --version', $ignoredOutput)) {
                     throw new \RuntimeException('Failed to clone ' . $this->url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
                 }
                 throw new \RuntimeException('Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" . $output);
             }
         }
     }
     $this->getTags();
     $this->getBranches();
 }
开发者ID:composer-fork,项目名称:composer,代码行数:35,代码来源:HgDriver.php

示例4: initialize

 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - file:        The file path or a php wrapper to log messages
  *                You can use any support php wrapper. To write logs to the Apache error log, use php://stderr
  * - format:      The log line format (default to %time% %type% [%priority%] %message%%EOL%)
  * - time_format: The log time strftime format (default to %b %d %H:%M:%S)
  * - dir_mode:    The mode to use when creating a directory (default to 0777)
  * - file_mode:   The mode to use when creating a file (default to 0666)
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean      true, if initialization completes successfully, otherwise false.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     if (!isset($options['file'])) {
         throw new sfConfigurationException('You must provide a "file" parameter for this logger.');
     }
     if (isset($options['format'])) {
         $this->format = $options['format'];
     }
     if (isset($options['time_format'])) {
         $this->timeFormat = $options['time_format'];
     }
     if (isset($options['type'])) {
         $this->type = $options['type'];
     }
     $dir = dirname($options['file']);
     if (!is_dir($dir)) {
         mkdir($dir, isset($options['dir_mode']) ? $options['dir_mode'] : 0777, true);
     }
     $fileExists = file_exists($options['file']);
     if (!is_writable($dir) || $fileExists && !is_writable($options['file'])) {
         throw new sfFileException(sprintf('Unable to open the log file "%s" for writing.', $options['file']));
     }
     $this->fp = fopen($options['file'], 'a');
     if (!$fileExists) {
         chmod($options['file'], isset($options['file_mode']) ? $options['file_mode'] : 0666);
     }
     return parent::initialize($dispatcher, $options);
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:45,代码来源:sfFileLogger.class.php

示例5: prepare_dir

 public static function prepare_dir($prefix)
 {
     $config = midcom_baseclasses_components_configuration::get('midcom.helper.filesync', 'config');
     $path = $config->get('filesync_path');
     if (!file_exists($path)) {
         $parent = dirname($path);
         if (!is_writable($parent)) {
             throw new midcom_error("Directory {$parent} is not writable");
         }
         if (!mkdir($path)) {
             throw new midcom_error("Failed to create directory {$path}. Reason: " . $php_errormsg);
         }
     }
     if (substr($path, -1) != '/') {
         $path .= '/';
     }
     $module_dir = "{$path}{$prefix}";
     if (!file_exists($module_dir)) {
         if (!is_writable($path)) {
             throw new midcom_error("Directory {$path} is not writable");
         }
         if (!mkdir($module_dir)) {
             throw new midcom_error("Failed to create directory {$module_dir}. Reason: " . $php_errormsg);
         }
     }
     return "{$module_dir}/";
 }
开发者ID:nemein,项目名称:openpsa,代码行数:27,代码来源:interfaces.php

示例6: template

 /**
  * Compiles a template and writes it to a cache file, which is used for inclusion.
  *
  * @param string $file The full path to the template that will be compiled.
  * @param array $options Options for compilation include:
  *        - `path`: Path where the compiled template should be written.
  *        - `fallback`: Boolean indicating that if the compilation failed for some
  *                      reason (e.g. `path` is not writable), that the compiled template
  *                      should still be returned and no exception be thrown.
  * @return string The compiled template.
  */
 public static function template($file, array $options = array())
 {
     $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates';
     $defaults = array('path' => $cachePath, 'fallback' => false);
     $options += $defaults;
     $stats = stat($file);
     $oname = basename(dirname($file)) . '_' . basename($file, '.php');
     $oname .= '_' . ($stats['ino'] ?: hash('md5', $file));
     $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php";
     $template = "{$options['path']}/{$template}";
     if (file_exists($template)) {
         return $template;
     }
     $compiled = static::compile(file_get_contents($file));
     if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) {
         foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) {
             if ($expired !== $template) {
                 unlink($expired);
             }
         }
         return $template;
     }
     if ($options['fallback']) {
         return $file;
     }
     throw new TemplateException("Could not write compiled template `{$template}` to cache.");
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:38,代码来源:Compiler.php

示例7: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
     $oldCacheDir = $realCacheDir . '_old';
     $filesystem = $this->getContainer()->get('filesystem');
     if (!is_writable($realCacheDir)) {
         throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
     }
     if ($filesystem->exists($oldCacheDir)) {
         $filesystem->remove($oldCacheDir);
     }
     $kernel = $this->getContainer()->get('kernel');
     $output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
     $this->getContainer()->get('cache_clearer')->clear($realCacheDir);
     if ($input->getOption('no-warmup')) {
         $filesystem->rename($realCacheDir, $oldCacheDir);
     } else {
         // the warmup cache dir name must have the same length than the real one
         // to avoid the many problems in serialized resources files
         $warmupDir = substr($realCacheDir, 0, -1) . '_';
         if ($filesystem->exists($warmupDir)) {
             $filesystem->remove($warmupDir);
         }
         $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
         $filesystem->rename($realCacheDir, $oldCacheDir);
         if (defined('PHP_WINDOWS_VERSION_BUILD')) {
             sleep(1);
             // workaround for windows php rename bug
         }
         $filesystem->rename($warmupDir, $realCacheDir);
     }
     $filesystem->remove($oldCacheDir);
 }
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:36,代码来源:CacheClearCommand.php

示例8: __construct

 /**
  * Constructor.
  * Requires a path to an existing and writable file.
  * 
  * @param string $outputPath path to file to write schema changes to. 
  */
 public function __construct($outputPath)
 {
     if (!file_exists($outputPath) || !is_writable($outputPath)) {
         throw new RedBean_Exception_Security('Cannot write to file: ' . $outputPath);
     }
     $this->file = $outputPath;
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:13,代码来源:TimeLine.php

示例9: getStep2

 public function getStep2()
 {
     $this->layout->step = 2;
     $data['req']['php_version'] = PHP_VERSION_ID >= 50400;
     $data['req']['mcrypt'] = extension_loaded('mcrypt');
     $data['req']['pdo'] = extension_loaded('pdo_mysql');
     if (function_exists('apache_get_modules')) {
         $data['req']['rewrite'] = in_array('mod_rewrite', apache_get_modules());
     }
     $dirs = array($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/', $_SERVER['DOCUMENT_ROOT'] . '/apps/backend/storage/', $_SERVER['DOCUMENT_ROOT'] . '/upload/', $_SERVER['DOCUMENT_ROOT'] . '/install/', $_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/config/', $_SERVER['DOCUMENT_ROOT'] . '/apps/backend/config/');
     foreach ($dirs as $path) {
         $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
         foreach ($iterator as $item) {
             @chmod($item, 0777);
         }
     }
     $data['req']['wr_fr_storage'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/');
     $data['req']['wr_bk_storage'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/backend/storage/');
     $data['req']['wr_upload'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/upload/');
     $data['req']['wr_install'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/install/');
     $data['req']['wr_fr_db'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/config/');
     $data['req']['wr_bk_db'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/backend/config/');
     $data['valid_step'] = true;
     foreach ($data['req'] as $valid) {
         $data['valid_step'] = $data['valid_step'] && $valid;
     }
     Session::put('step2', $data['valid_step']);
     $this->layout->content = View::make('install::step2', $data);
     return $this->layout;
 }
开发者ID:vcorobceanu,项目名称:WebAPL,代码行数:30,代码来源:InstallController.php

示例10: storeEntity

 /**
  * Storing entity by ORM table
  *
  * @access public
  * @return boolean
  */
 public function storeEntity($buffer = null)
 {
     try {
         // Data posted required, otherwise avoid write anything
         if (!$buffer) {
             throw new JMapException(JText::_('COM_JMAP_HTACCESS_NO_DATA'), 'error');
         }
         $targetHtaccess = null;
         // Find htaccess file
         if (JFile::exists(JPATH_ROOT . '/.htaccess')) {
             $targetHtaccess = JPATH_ROOT . '/.htaccess';
         } elseif (JFile::exists(JPATH_ROOT . '/htaccess.txt')) {
             // Fallback on txt dummy version
             $targetHtaccess = JPATH_ROOT . '/htaccess.txt';
             $this->setState('htaccess_version', 'textual');
         } else {
             throw new JMapException(JText::_('COM_JMAP_HTACCESS_NOTFOUND'), 'error');
         }
         // If file permissions ko on rewrite updated contents
         if (!is_writable($targetHtaccess)) {
             @chmod($targetHtaccess, 0777);
         }
         if (@(!JFile::write($targetHtaccess, $buffer))) {
             throw new JMapException(JText::_('COM_JMAP_ERROR_WRITING_HTACCESS'), 'error');
         }
     } catch (JMapException $e) {
         $this->setError($e);
         return false;
     } catch (Exception $e) {
         $jmapException = new JMapException($e->getMessage(), 'error');
         $this->setError($jmapException);
         return false;
     }
     return true;
 }
开发者ID:site4com,项目名称:prometheus,代码行数:41,代码来源:htaccess.php

示例11: dowork

function dowork()
{
    $canIhaveAccess = 0;
    $canIhaveAccess = $canIhaveAccess + checklevel('admin');
    if ($canIhaveAccess == 1) {
        if (is_writable('settings.php') == 0) {
            die("Error: settings.php is not writeable.");
        }
        if (isset($_REQUEST['action'])) {
            $action = $_REQUEST['action'];
        } else {
            $action = "view";
        }
        if ($action == "view") {
            $config = new pliggconfig();
            if (isset($_REQUEST['page'])) {
                $config->var_page = $_REQUEST['page'];
                $config->showpage();
            }
        }
        if ($action == "save") {
            $config = new pliggconfig();
            $config->var_id = substr($_REQUEST['var_id'], 6, 10);
            $config->var_value = $_REQUEST['var_value'];
            $config->store();
        }
    }
}
开发者ID:bendroid,项目名称:pligg-cms,代码行数:28,代码来源:delete.php

示例12: save_future_list

 public static function save_future_list($list, $save_type = FILE_APPEND)
 {
     $file = self::get_parent_dir() . self::$future_list_file;
     $data_to_write = '';
     $errors = array();
     if (!file_exists($file)) {
         $f = fopen($file, 'w');
         if ($f === false) {
             $errors['error'] = "Cannot crete future list file <code>" . $file . "</code>";
         } else {
             fclose($f);
         }
     }
     foreach ($list as $el) {
         $data_to_write .= trim($el['name']) . " ::: " . $el['link'] . "\n";
     }
     if (is_writable($file)) {
         if (file_put_contents($file, $data_to_write, $save_type) == false) {
             $errors['error'] = 'Cannot write to file <code>' . $file . "</code>";
         }
     } else {
         $errors['error'] = 'File is not writable <code>' . $file . "</code>";
     }
     return $errors;
 }
开发者ID:flotzilla,项目名称:rtracker,代码行数:25,代码来源:Utils.php

示例13: addIndexFile

 private static function addIndexFile($path)
 {
     if (file_exists($path) || !is_writable($path)) {
         return;
     }
     file_put_contents($path . 'index.php', '<?php header("location: ../index.php"); die;');
 }
开发者ID:ameoba32,项目名称:tiki,代码行数:7,代码来源:CleanVendors.php

示例14: check

 public function check()
 {
     if (phpversion() < '5.0.0') {
         return Response::json(FAIL, array('您的php版本过低,不能安装本软件,请升级到5.0.0或更高版本再安装,谢谢!'));
     }
     if (!extension_loaded('PDO')) {
         return Response::json(FAIL, array('请加载PHP的PDO模块,谢谢!'));
     }
     if (!function_exists('session_start')) {
         return Response::json(FAIL, array('请开启session,谢谢!'));
     }
     if (!is_writable(ROOT_PATH)) {
         return Response::json(FAIL, array('请保证代码目录有写权限,谢谢!'));
     }
     $config = (require CONFIG_PATH . 'mysql.php');
     try {
         $mysql = new PDO('mysql:host=' . $config['master']['host'] . ';port=' . $config['master']['port'], $config['master']['user'], $config['master']['pwd']);
     } catch (Exception $e) {
         return Response::json(FAIL, array('请正确输入信息连接mysql,保证启动mysql,谢谢!'));
     }
     $mysql->exec('CREATE DATABASE ' . $config['master']['dbname']);
     $mysql = null;
     unset($config);
     return Response::json(SUCC, array('检测通过'));
 }
开发者ID:swg0110,项目名称:iBarn,代码行数:25,代码来源:Install.class.php

示例15: isWritable

 function isWritable($sFile, $sPrePath = '/../../')
 {
     clearstatcache();
     $aPathInfo = pathinfo(__FILE__);
     $sFile = $aPathInfo['dirname'] . '/../../' . $sFile;
     return is_readable($sFile) && is_writable($sFile);
 }
开发者ID:Gotgot59,项目名称:dolphin.pro,代码行数:7,代码来源:BxDolIO.php


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