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


PHP f::niceSize方法代码示例

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


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

示例1: memory

/**
 * Returns the memory usage in a readable format
 *
 * @return string
 */
function memory()
{
    return f::niceSize(memory_get_usage());
}
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:9,代码来源:helpers.php

示例2: niceSize

 /**
  * Returns the human readable version of the file size
  *
  * @return string
  */
 public function niceSize()
 {
     return f::niceSize($this->size());
 }
开发者ID:kgchoy,项目名称:main-portfolio-website,代码行数:9,代码来源:media.php

示例3: messages

 protected function messages()
 {
     return array(static::ERROR_MISSING_FILE => 'The file is missing', static::ERROR_MISSING_TMP_DIR => 'The /tmp directory is missing on your server', static::ERROR_FAILED_UPLOAD => 'The upload failed', static::ERROR_PARTIAL_UPLOAD => 'The file has been only been partially uploaded', static::ERROR_UNALLOWED_OVERWRITE => 'The file exists and cannot be overwritten', static::ERROR_MAX_SIZE => 'The file is too big. The maximum size is ' . f::niceSize($this->maxSize()), static::ERROR_MOVE_FAILED => 'The file could not be moved', static::ERROR_UNACCEPTED => 'The file is not accepted by the server');
 }
开发者ID:irenehilber,项目名称:kirby-base,代码行数:4,代码来源:upload.php

示例4: checkUpload

 protected function checkUpload($file, $blueprint)
 {
     if (strtolower($file->extension()) == kirby()->option('content.file.extension', 'txt')) {
         throw new Exception('Content files cannot be uploaded');
     } else {
         if (strtolower($file->extension()) == 'php' or str::contains($file->extension(), 'php') or in_array($file->mime(), f::$mimes['php'])) {
             throw new Exception('PHP files cannot be uploaded');
         } else {
             if (strtolower($file->extension()) == 'html' or $file->mime() == 'text/html') {
                 throw new Exception('HTML files cannot be uploaded');
             } else {
                 if (strtolower($file->extension()) == 'exe' or $file->mime() == 'application/x-msdownload') {
                     throw new Exception('EXE files cannot be uploaded');
                 } else {
                     if (strtolower($file->filename()) == '.htaccess') {
                         throw new Exception('htaccess files cannot be uploaded');
                     } else {
                         if (str::startsWith($file->filename(), '.')) {
                             throw new Exception('Invisible files cannot be uploaded');
                             // Files blueprint option 'type'
                         } else {
                             if (count($blueprint->files()->type()) > 0 and !in_array($file->type(), $blueprint->files()->type())) {
                                 throw new Exception('Page only allows: ' . implode(', ', $blueprint->files()->type()));
                                 // Files blueprint option 'size'
                             } else {
                                 if ($blueprint->files()->size() and f::size($file->root()) > $blueprint->files()->size()) {
                                     throw new Exception('Page only allows file size of ' . f::niceSize($blueprint->files()->size()));
                                     // Files blueprint option 'width'
                                 } else {
                                     if ($file->type() == 'image' and $blueprint->files()->width() and $file->width() > $blueprint->files()->width()) {
                                         throw new Exception('Page only allows image width of ' . $blueprint->files()->width() . 'px');
                                         // Files blueprint option 'height'
                                     } else {
                                         if ($file->type() == 'image' and $blueprint->files()->height() and $file->height() > $blueprint->files()->height()) {
                                             throw new Exception('Page only allows image height of ' . $blueprint->files()->height() . 'px');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:46,代码来源:files.php

示例5: niceSize

 /**
  * Returns a nicely formatted size of all the contents of the folder
  *
  * @param string $dir The path of the directory
  * @param boolean $recursive
  * @return mixed
  */
 public static function niceSize($dir)
 {
     return f::niceSize(static::size($dir));
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:11,代码来源:dir.php

示例6: checkUpload

 public function checkUpload($file)
 {
     $filesettings = $this->blueprint->files();
     $forbiddenExtensions = array('php', 'html', 'htm', 'exe', kirby()->option('content.file.extension', 'txt'));
     $forbiddenMimes = array_merge(f::$mimes['php'], array('text/html', 'application/x-msdownload'));
     $extension = strtolower($file->extension());
     // files without extension are not allowed
     if (empty($extension)) {
         throw new Exception(l('files.add.error.extension.missing'));
     }
     // block forbidden extensions
     if (in_array($extension, $forbiddenExtensions)) {
         throw new Exception(l('files.add.error.extension.forbidden'));
     }
     // especially block any connection that contains php
     if (str::contains($extension, 'php')) {
         throw new Exception(l('files.add.error.extension.forbidden'));
     }
     // block forbidden mimes
     if (in_array(strtolower($file->mime()), $forbiddenMimes)) {
         throw new Exception(l('files.add.error.mime.forbidden'));
     }
     // Block htaccess files
     if (strtolower($file->filename()) == '.htaccess') {
         throw new Exception(l('files.add.error.htaccess'));
     }
     // Block invisible files
     if (str::startsWith($file->filename(), '.')) {
         throw new Exception(l('files.add.error.invisible'));
     }
     // Files blueprint option 'type'
     if (count($filesettings->type()) > 0 and !in_array($file->type(), $filesettings->type())) {
         throw new Exception(l('files.add.blueprint.type.error') . implode(', ', $filesettings->type()));
     }
     // Files blueprint option 'size'
     if ($filesettings->size() and f::size($file->root()) > $filesettings->size()) {
         throw new Exception(l('files.add.blueprint.size.error') . f::niceSize($filesettings->size()));
     }
     // Files blueprint option 'width'
     if ($file->type() == 'image' and $filesettings->width() and $file->width() > $filesettings->width()) {
         throw new Exception('Page only allows image width of ' . $filesettings->width() . 'px');
     }
     // Files blueprint option 'height'
     if ($file->type() == 'image' and $filesettings->height() and $file->height() > $filesettings->height()) {
         throw new Exception('Page only allows image height of ' . $filesettings->height() . 'px');
     }
 }
开发者ID:robinandersen,项目名称:robin,代码行数:47,代码来源:uploader.php

示例7: testNiceSize

 public function testNiceSize()
 {
     $this->assertEquals('37 b', f::niceSize($this->contentFile));
     $this->assertEquals('37 b', f::niceSize(37));
 }
开发者ID:aoimedia,项目名称:kosmonautensofa,代码行数:5,代码来源:FTest.php


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