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


PHP DirectoryIterator::isWritable方法代码示例

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


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

示例1: generate

 /**
  * Generate app skeleton on current directory
  *
  * @param  string Namespace
  * @return stream
  */
 public static function generate($namespace = 'App')
 {
     $namespace = ucfirst(strtolower($namespace));
     $isApp = (bool) ($namespace === 'App');
     $currentDirectory = new \DirectoryIterator($_SERVER['PWD']);
     // Initialize by validate current directory
     if ($currentDirectory->isDir() && $currentDirectory->isWritable()) {
         // Create directory structure
         self::out(I18n::translate('command_generate_folders'));
         $appFolder = $currentDirectory->getPath() . DIRECTORY_SEPARATOR . $namespace;
         $controllerFolder = $currentDirectory->getPath() . DIRECTORY_SEPARATOR . $namespace . DIRECTORY_SEPARATOR . 'Controller';
         $testsFolder = $currentDirectory->getPath() . DIRECTORY_SEPARATOR . $namespace . DIRECTORY_SEPARATOR . 'Tests';
         $directories = compact('appFolder', 'controllerFolder', 'testsFolder');
         foreach ($directories as $name => $directory) {
             $directory = $isApp ? str_replace($namespace, strtolower($namespace), $directory) : $directory;
             is_dir($directory) or mkdir($directory, 0755, TRUE);
             // Reset paths
             ${$name} = $directory;
         }
         // Create controller and model
         self::out(I18n::translate('command_generate_files'));
         $controllerTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'Controller.php.tpl');
         $phpunitTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'phpunit.xml.tpl');
         $bootstrapTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'bootstrap.php.tpl');
         $testTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'ControllerTest.php.tpl');
         $routePath = $isApp ? '' : strtolower($namespace) . '.';
         File::write($controllerFolder . DIRECTORY_SEPARATOR . 'HelloController.php', sprintf($controllerTemplate, $namespace, $namespace, $namespace));
         File::write($testsFolder . DIRECTORY_SEPARATOR . 'phpunit.xml', sprintf($phpunitTemplate, $namespace));
         File::write($testsFolder . DIRECTORY_SEPARATOR . 'bootstrap.php', sprintf($bootstrapTemplate, PATH_SYS . DIRECTORY_SEPARATOR . 'Juriya.php'));
         File::write($testsFolder . DIRECTORY_SEPARATOR . 'HelloControllerTest.php', sprintf($testTemplate, $namespace, $namespace, $routePath, $routePath, $routePath));
         // Generate basic YAML configuration files
         self::out(I18n::translate('command_generate_configuration'));
         $routesTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'routes.yml.tpl');
         $packagesTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'packages.yml.tpl');
         $modulesTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'modules.yml.tpl');
         File::write($appFolder . DIRECTORY_SEPARATOR . 'routes.yml', sprintf($routesTemplate, $namespace));
         File::write($appFolder . DIRECTORY_SEPARATOR . 'packages.yml', $packagesTemplate);
         File::write($appFolder . DIRECTORY_SEPARATOR . 'modules.yml', $modulesTemplate);
         if ($isApp) {
             // Generate front socket if the requsted app is Application
             self::out(I18n::translate('command_generate_front_socket'));
             $publicDirectory = $currentDirectory->getPath() . DIRECTORY_SEPARATOR . 'public';
             is_dir($publicDirectory) or mkdir($publicDirectory, 0755, TRUE);
             $indexTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'index.php.tpl');
             File::write($publicDirectory . DIRECTORY_SEPARATOR . 'index.php', sprintf($indexTemplate, PATH_SYS . DIRECTORY_SEPARATOR . 'Juriya.php'));
         }
         self::out(Utility::getColoredString(I18n::translate('command_generate_done'), 'black', 'green'));
     } else {
         self::out(I18n::translate('file_not_writable', $currentDirectory->getPath()));
         self::out(Utility::getColoredString(I18n::translate('command_generate_fail'), 'black', 'red'));
     }
 }
开发者ID:nurcahyo,项目名称:juriya,代码行数:58,代码来源:Console.php

示例2: getRootDirFiles

    /**
     * @return array
     * @throws Exception
     */
    public function getRootDirFiles()
    {

        $rootDirectoryIterator = new DirectoryIterator($this->getRootDir());

        if (!$rootDirectoryIterator->isWritable()) {
            throw new Exception('Root directory is not writable', 500);
        }

        $files = array();

        /**
         * @var $itr DirectoryIterator
         */
        foreach ($rootDirectoryIterator as $itr) {

            if ($itr->isDot() || $itr->isDir()) {
                continue;
            };

            $files[] = $itr->getFileInfo();

        }

        return $files;

    }
开发者ID:realfluid,项目名称:umbaugh,代码行数:31,代码来源:logs_update.php

示例3: buildTableRow

 public function buildTableRow(DirectoryIterator $file, $includeParentDirectoryDots = true)
 {
     if (!$file->isDot() && substr($file->getFilename(), 0, 1) == '.' && Administration::instance()->Configuration->get('show-hidden', 'filemanager') != 'yes') {
         return;
     } elseif ($file->isDot() && !$includeParentDirectoryDots && $file->getFilename() == '..') {
         return;
     } elseif ($file->getFilename() == '.') {
         return;
     }
     $relpath = str_replace($this->getStartLocation() == '' ? DOCROOT : DOCROOT . $this->getStartLocation(), NULL, $file->getPathname());
     if (!$file->isDir()) {
         //if(File::fileType($file->getFilename()) == self::CODE)
         //	$download_uri = self::baseURL() . 'edit/?file=' . urlencode($relpath);
         //else
         $download_uri = self::baseURL() . 'download/?file=' . urlencode($relpath);
     } else {
         $download_uri = self::baseURL() . 'properties/?file=' . urlencode($relpath) . '/';
     }
     if (!$file->isDot()) {
         $td1 = Widget::TableData(Widget::Anchor($file->getFilename(), self::baseURL() . ($file->isDir() ? 'browse' . $relpath . '/' : 'properties/?file=' . urlencode($relpath)), NULL, 'file-type ' . ($file->isDir() ? 'folder' : File::fileType($file->getFilename()))));
         //$group = (function_exists('posix_getgrgid') ? posix_getgrgid($file->getGroup()) : $file->getGroup());
         //$owner = (function_exists('posix_getpwuid') ? posix_getpwuid($file->getOwner()) : $file->getOwner());
         $group = $file->getGroup();
         $owner = $file->getOwner();
         $td3 = Widget::TableData(File::getOctalPermission($file->getPerms()) . ' <span class="inactive">' . File::getReadablePerm($file->getPerms()), NULL, NULL, NULL, array('title' => (isset($owner['name']) ? $owner['name'] : $owner) . ', ' . (isset($group['name']) ? $group['name'] : $group)) . '</span>');
         $td4 = Widget::TableData(DateTimeObj::get(__SYM_DATETIME_FORMAT__, $file->getMTime()));
         if ($file->isWritable()) {
             if ($file->isDir()) {
                 $td5 = Widget::TableData(Widget::Anchor('Edit', $download_uri));
             } else {
                 $td5 = Widget::TableData(Widget::Anchor('Download', $download_uri));
             }
         } else {
             $td5 = Widget::TableData('-', 'inactive');
         }
     } else {
         $td1 = Widget::TableData(Widget::Anchor('&crarr;', self::baseURL() . 'browse' . $relpath . '/'));
         $td3 = Widget::TableData('-', 'inactive');
         $td4 = Widget::TableData('-', 'inactive');
         $td5 = Widget::TableData('-', 'inactive');
     }
     $td2 = Widget::TableData($file->isDir() ? '-' : General::formatFilesize($file->getSize()), $file->isDir() ? 'inactive' : NULL);
     $startlocation = DOCROOT . $this->getStartLocation();
     if (!$file->isDot()) {
         $td5->appendChild(Widget::Input('items[' . str_replace($startlocation, '', $file->getPathname()) . ($file->isDir() ? '/' : NULL) . ']', NULL, 'checkbox'));
     }
     return Widget::TableRow(array($td1, $td2, $td3, $td4, $td5));
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:48,代码来源:extension.driver.php

示例4: DirectoryIterator

 $dir = new DirectoryIterator('/home/user/public_html/site');
 $i = 0;
 //varro o diretório procurando por arquivos acentuados
 foreach ($dir as $file) {
     $filename = $file->getFilename();
     //verifica se não é um diretório, ponto ('.' ou '..') e nem uma imagem
     if (!$file->isDot() && !$file->isDir() && !preg_match('/\\.jpg/', $filename)) {
         //usa os métodos da classe Validation para formar um nome de arquivo funcional
         $filename_normalized = Validation::normalize($filename, false);
         $final_filename = Validation::removeRepeatedChars($filename_normalized, false, true);
         //operações no banco (caso o arquivo esteja vinculado ao banco)
         $sql = 'SELECT `id` FROM `arquivos` WHERE `arq1` = \'' . $filename . '\'';
         $r = mysql_query($sql) or die('Problema na query do bd<br />' . mysql_error());
         $db = mysql_fetch_object($r);
         echo '<br />---------------------------------------------<br />';
         echo "Nome: {$filename} - ID no banco: {$db->id}<br />Nome final: {$final_filename}<br />Posso escrever: " . $dir->isWritable();
         //Altero os arquivos agora e seu valor no bd
         if ($db->id && rename('../uploads/' . $filename, '../uploads/' . $final_filename)) {
             $sql = 'UPDATE `amarildo_amarildo`.`arquivos` SET `arq1` = \'' . $final_filename . '\' WHERE `arquivos`.`id` = ' . $db->id . ' LIMIT 1';
             if (mysql_query($sql)) {
                 echo "<br />Arquivo renomeado com sucesso!";
             } else {
                 echo "<br />Não foi possível atualizar o banco";
             }
         } else {
             echo "<br />Não foi possível renomear o arquivo {$filename} <br />";
         }
         $i++;
     }
 }
 echo "<br /><h2>Total de arquivos: {$i}</h2>";
开发者ID:CauanCabral,项目名称:libs,代码行数:31,代码来源:corrigi_acentuados.php

示例5: label

}
$home = $_SERVER['HOME'];
$account_user = $_SERVER['LOGNAME'];
$begin_script = time();
function label($text)
{
    return "\n[" . date('r') . "] " . $text . "\n";
}
echo "#################################################\n";
echo "### Starting dreamhost account backup process ###\n";
echo "###      " . date('r') . "      ###\n";
echo "#################################################\n";
try {
    // Check if we can read/write to mysql subdir chosen
    $mysql_arquives = new DirectoryIterator($home . '/' . $backups_dir . '/' . $mysql_subdir);
    if (!$mysql_arquives->isReadable() || !$mysql_arquives->isWritable()) {
        throw new RuntimeException('No read or write access.');
    }
} catch (RuntimeException $e) {
    exit("Please make sure you provide a valid folder for the arquives, with read and write access.\n");
}
// Return an array with stdClass objects from API commands
function request_api($cmd)
{
    $api_key = $_SERVER['argv'][1];
    $xml = new SimpleXMLElement('https://api.dreamhost.com/?key=' . $api_key . '&cmd=' . $cmd . '&format=xml', null, true);
    if ((string) $xml->result != 'success') {
        exit("Request for '{$cmd}' unsuccessful.\n");
    }
    // Use json decode/encode to convert the SimpleXMLElement objects into stdClass objects
    return json_decode(json_encode($xml->xpath('/dreamhost/data')));
开发者ID:helderco,项目名称:Dreamhost-Full-Auto-Backup,代码行数:31,代码来源:dreamhost.backup.php

示例6: _getItemStats

 /**
  * Determine file/directory statistics for input item.
  *
  * @param DirectoryIterator $item Item passed from a DirectoryIterator
  * @return array Listing with stats
  */
 private static function _getItemStats(DirectoryIterator $item)
 {
     $list = array();
     // add filename
     $list['name'] = (string) $item;
     // add directory/file type
     $list['type'] = $item->getType();
     // add modification time
     $list['modified'] = date('Y-m-d H:i:s', $item->getMTime());
     // get permissions
     $list['permissions'] = $item->getPerms();
     // is writable?
     $list['writable'] = $item->isWritable() ? 1 : 0;
     // add path
     $list['path'] = $item->getPathName();
     $list['real_path'] = $item->getRealPath();
     // add size
     $list['size'] = Fari_Format::bytes($item->getSize());
     return $list;
 }
开发者ID:radekstepan,项目名称:PumpedBlog,代码行数:26,代码来源:File.php


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