當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。