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


PHP parse_size函数代码示例

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


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

示例1: file_upload_max_size

/**
 * Determine the maximum file upload size by querying the PHP settings.
 *
 * @return
 *   A file size limit in bytes based on the PHP upload_max_filesize and
 *   post_max_size
 */
function file_upload_max_size()
{
    static $max_size;
    if (isset($max_size)) {
        return $max_size;
    }
    $upload_max = parse_size(ini_get('upload_max_filesize'));
    $post_max = parse_size(ini_get('post_max_size'));
    $max_size = min($upload_max, $post_max);
    return $max_size;
}
开发者ID:WIZARDISHUNGRY,项目名称:sflimetracker,代码行数:18,代码来源:ApacheConfigHelper.php

示例2: file_upload_max_size

function file_upload_max_size()
{
    static $max_size = -1;
    if ($max_size < 0) {
        $max_size = parse_size(ini_get('post_max_size'));
        $upload_max = parse_size(ini_get('upload_max_filesize'));
        if ($upload_max > 0 && $upload_max < $max_size) {
            $max_size = $upload_max;
        }
    }
    return $max_size;
}
开发者ID:agreements,项目名称:neofrag-cms,代码行数:12,代码来源:file.php

示例3: get_maxloadsize

/**	function used to get the numeration of entites
 *	return array $entitynum - numertaion of entities
 */
function get_maxloadsize()
{
    require_once 'include/utils/UserInfoUtil.php';
    require_once 'modules/Users/Users.php';
    global $adb, $log, $current_user;
    $log->debug("Entering vtws_get_maxloadsize ()");
    $max_size = parse_size(ini_get('post_max_size'));
    // If upload_max_size is less, then reduce. Except if upload_max_size is
    // zero, which indicates no limit.
    $upload_max = parse_size(ini_get('upload_max_filesize'));
    if ($upload_max > 0 && $upload_max < $max_size) {
        $max_size = $upload_max;
    }
    $log->debug("Exiting get_maxloadsize");
    return $max_size;
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:19,代码来源:getmaxloadsize.php

示例4: show_file

function show_file($file_name)
{
    global $newPath, $BASE_DIR, $BASE_URL, $FILE_ROOT;
    $size = filesize($BASE_DIR . $FILE_ROOT . $file_name);
    $ext = getExtension($BASE_DIR . $FILE_ROOT . $file_name);
    if (!is_file(getcwd() . "/icons/" . $ext . ".gif")) {
        $ext = "def";
    }
    ?>
<td>
<table width="102" border="0" cellpadding="0" cellspacing="2">
  <tr> 
    <td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
	  <a href="javascript:;" onClick="fileSelected('<?php 
    echo $newPath . "/" . $file_name;
    ?>
','<?php 
    echo $file_name . " (" . parse_size($size) . ")";
    ?>
')">
		<img src="icons/<?php 
    echo $ext;
    ?>
.gif" width="48" height="48" border=0 alt="<?php 
    echo $file_name . " (" . parse_size($size) . ")";
    ?>
">
	  </a>
	</td>
  </tr>
  <tr> 
    <td><table width="100%" border="0" cellspacing="1" cellpadding="2">
        <tr> 
          <td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
			<a href="files.php?delFile=<?php 
    echo $file_name;
    ?>
&dir=<?php 
    echo $newPath;
    ?>
" onClick="return deleteFile('<?php 
    echo $file_name;
    ?>
');"><img src="images/edit_trash.gif" width="15" height="15" border="0" alt="Delete this file"></a></td>
          <td width="99%" class="imgCaption"><?php 
    echo $file_name;
    ?>
</td>
        </tr>
      </table></td>
  </tr>
</table>
</td>
<?php 
}
开发者ID:rrecurse,项目名称:IntenseCart,代码行数:55,代码来源:files.php

示例5: parse_size

/* get max. file size from php.ini configuration */
function parse_size($size)
{
    $unit = preg_replace('/[^bkmgtpezy]/i', '', $size);
    // Remove the non-unit characters from the size.
    $size = preg_replace('/[^0-9\\.]/', '', $size);
    // Remove the non-numeric characters from the size.
    if ($unit) {
        // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
        return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
    } else {
        return round($size);
    }
}
$maxFileSize = parse_size(ini_get('post_max_size')) < parse_size(ini_get('upload_max_filesize')) ? ini_get('post_max_size') : ini_get('upload_max_filesize');
try {
    //if file exceeded the filesize, no file will be sent
    if (!isset($_FILES['uploadedFile'])) {
        throw new RuntimeException("No file sent, you must upload a (.axp) file not greater than {$maxFileSize}");
    }
    $file = pathinfo($_FILES['uploadedFile']['name']);
    $ext = $file['extension'];
    // get the extension of the file
    $filename = $file['filename'];
    // Undefined | Multiple Files | $_FILES Corruption Attack
    // If this request falls under any of them, treat it invalid.
    // Check $_FILES['uploadedFile']['error'] value.
    switch ($_FILES['uploadedFile']['error']) {
        case UPLOAD_ERR_OK:
            break;
开发者ID:TokaMElTorkey,项目名称:northwind,代码行数:30,代码来源:upload-ajax.php

示例6: parse_size

$size = 0;
$size = @ini_get('upload_max_filesize');
if ($size) {
    $size = parse_size($size);
}
if ($size > 0) {
    $ts = @ini_get('post_max_size');
    if ($ts) {
        $ts = parse_size($size);
    }
    if ($ts > 0) {
        $size = min($size, $ts);
    }
    $ts = @ini_get('memory_limit');
    if ($ts) {
        $ts = parse_size($size);
    }
    if ($ts > 0) {
        $size = min($size, $ts);
    }
}
if (empty($size)) {
    $size = '';
} else {
    $size = sizecount($size);
}
$info['limit'] = $size;
$sql = 'SELECT VERSION();';
$info['mysql']['version'] = pdo_fetchcolumn($sql);
$tables = pdo_fetchall("SHOW TABLE STATUS LIKE '" . $_W['config']['db']['tablepre'] . "%'");
$size = 0;
开发者ID:ChainBoy,项目名称:wxfx,代码行数:31,代码来源:sysinfo.ctrl.php

示例7: gettext

			<p class="notebox">
				<?php 
echo gettext('<strong>Note: </strong>');
?>
				<br />
				<?php 
if ($last == 'ZIP') {
    echo gettext('ZIP files must contain only supported <em>image</em> types.');
    ?>
					<br />
					<?php 
}
$maxupload = ini_get('upload_max_filesize');
$maxpost = ini_get('post_max_size');
$maxuploadint = parse_size($maxupload);
$maxpostint = parse_size($maxpost);
if ($maxuploadint < $maxpostint) {
    echo sprintf(gettext("The maximum size for any one file is <strong>%sB</strong> and the maximum size for one total upload is <strong>%sB</strong> which are set by your PHP configuration <code>upload_max_filesize</code> and <code>post_max_size</code>."), $maxupload, $maxpost);
} else {
    echo ' ' . sprintf(gettext("The maximum size for your total upload is <strong>%sB</strong> which is set by your PHP configuration <code>post_max_size</code>."), $maxpost);
}
$uploadlimit = zp_apply_filter('get_upload_limit', $maxuploadint);
$maxuploadint = min($maxuploadint, $uploadlimit);
?>
				<br />
				<?php 
echo zp_apply_filter('get_upload_header_text', gettext('Don’t forget, you can also use <acronym title="File Transfer Protocol">FTP</acronym> to upload folders of images into the albums directory!'));
?>
			</p>
			<?php 
if (isset($_GET['error'])) {
开发者ID:ariep,项目名称:ZenPhoto20-DEV,代码行数:31,代码来源:admin-upload.php

示例8: get_byte

function get_byte($raw)
{
    // $raw : '500kb', '1mb'
    require_once 'lib/byte_converter.class.php';
    $file_raw_size = parse_size($raw);
    $size_in_byte = 0;
    try {
        $byte = new byte_converter();
        $byte->set_limit("tb");
        //show types up to tera byte
        $file_size = $byte->auto($file_raw_size[0], $file_raw_size[1]);
        $size_in_byte = $file_size['b'];
    } catch (Exception $e) {
        echo $e;
    }
    return $size_in_byte;
}
开发者ID:ravinderphp,项目名称:skfood,代码行数:17,代码来源:fns_tinybrowser.php

示例9: show_image

function show_image($img, $file, $info, $size, $listdir, $i)
{
    $img_file = basename($img);
    $img_url_link = _FPSSLIVESITE . $listdir . "/" . rawurlencode($img_file);
    $filesize = parse_size($size);
    if ($info[0] > 120 || $info[0] > 120) {
        $img_dimensions = imageResize($info[0], $info[1], 120);
    } else {
        $img_dimensions = 'width="' . $info[0] . '" height="' . $info[1] . '"';
    }
    ?>
		<tr>
  			<td><img id="image<?php 
    echo $i;
    ?>
" onmouseover="this.style.cursor='pointer'" onclick="javascript:sendtomain(<?php 
    echo $i;
    ?>
);" src="<?php 
    echo $img_url_link;
    ?>
" <?php 
    echo $img_dimensions;
    ?>
 border="0" /></td>
  			<td><b><?php 
    echo htmlspecialchars(substr($file, 0, 20) . (strlen($file) > 20 ? '...' : ''), ENT_QUOTES);
    ?>
</b></td>
  			<td><b class="red"><?php 
    echo $info[0];
    ?>
x<?php 
    echo $info[1];
    ?>
px</b></td>
  			<td><?php 
    echo $filesize;
    ?>
</td>
		</tr>
		<?php 
}
开发者ID:bizanto,项目名称:Hooked,代码行数:43,代码来源:fpss.php

示例10: getValidators

 protected function getValidators()
 {
     $extensions = array();
     $types = file_type_get_enabled_types();
     foreach ($types as $t => $type) {
         $extensions = array_merge($extensions, _os_files_extensions_from_type($t));
     }
     $validators = array('file_validate_extensions' => array(implode(' ', $extensions)), 'file_validate_size' => array(parse_size(file_upload_max_size())));
     return $validators;
 }
开发者ID:aleph-n,项目名称:opencholar,代码行数:10,代码来源:OsFilesResource.class.php

示例11: show_image

function show_image($img, $file, $info, $size)
{
    global $BASE_DIR, $BASE_URL, $newPath;
    $img_path = dir_name($img);
    $img_file = basename($img);
    $thumb_image = 'thumbs.php?img=' . urlencode($img);
    $img_url = $BASE_URL . $img_path . '/' . $img_file;
    $filesize = parse_size($size);
    ?>
<td>
<table width="102" border="0" cellpadding="0" cellspacing="2">
  <tr> 
    <td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
	<a href="javascript:;" onClick="javascript:imageSelected('<?php 
    echo $img_url;
    ?>
', <?php 
    echo $info[0];
    ?>
, <?php 
    echo $info[1];
    ?>
,'<?php 
    echo $file;
    ?>
');"><img src="<?php 
    echo $thumb_image;
    ?>
" alt="<?php 
    echo $file;
    ?>
 - <?php 
    echo $filesize;
    ?>
" border="0"></a></td>
  </tr>
  <tr> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr> 
          <td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
			<a href="javascript:;" onClick="javascript:preview('<?php 
    echo $img_url;
    ?>
', '<?php 
    echo $file;
    ?>
', ' <?php 
    echo $filesize;
    ?>
',<?php 
    echo $info[0] . ',' . $info[1];
    ?>
);"><img src="edit_pencil.gif" width="15" height="15" border="0"></a></td>
          <td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
			<a href="images.php?delFile=<?php 
    echo $img_url;
    ?>
&dir=<?php 
    echo $newPath;
    ?>
" onClick="return deleteImage('<?php 
    echo $file;
    ?>
');"><img src="edit_trash.gif" width="15" height="15" border="0"></a></td>
          <td width="98%" class="imgCaption"><?php 
    echo $info[0] . 'x' . $info[1];
    ?>
</td>
        </tr>
      </table></td>
  </tr>
</table>
</td>
<?php 
}
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:75,代码来源:images.php

示例12: sanitize

                     <td width="0px" style="display: none;">&nbsp;</td>
                 <td width="0px" style="display: none;">' . $time . '</td>
                     </tr>';
     $folderJSArray .= "['img/ext/folder_small.gif', '" . sanitize($entry) . "', '" . _filemanager_folder . "', '" . $parsed_time . "'],\n";
     $folderNb++;
 } else {
     $entries_cnt++;
     $ext = substr(strrchr($entry, '.'), 1);
     if (is_array($MY_LIST_EXTENSIONS)) {
         if (!in_array(strtolower($ext), $MY_LIST_EXTENSIONS)) {
             continue;
         }
     }
     $size = filesize($absolutePath);
     $time = filemtime($absolutePath);
     $parsed_size = parse_size($size);
     $parsed_time = parse_time($time);
     $parsed_icon = 'img/ext/' . parse_icon($ext);
     $css_class = $ext . '_bg';
     #need to take img out and replace by css style
     # <td width="4%"><img src="'.$parsed_icon.'" width="16" height="16" border="0" alt="'.$entry.'" /></td>
     $t_files .= '<tr id="F' . $fileNb++ . '">
                     <td width="50%"><div  style="height:15px; overflow:hidden;"
                     					><a class="' . $css_class . '" href="javascript:;" onClick="javascript:fileSelected(\'' . $MY_BASE_URL . $relativePath . '\',\'' . $entry . '\',\'' . $parsed_icon . '\',\'' . $parsed_size . '\',\'' . $parsed_time . '\');">' . $entry . '</div></td>
                     <td width="18%" align="right">' . $parsed_size . '</td>
                     <td width="25%">' . $parsed_time . '</td>
                     <td width="0px" style="display: none;">' . $ext . '</td>
                     <td width="0px" style="display: none;">' . $size . '</td>
                     <td width="0px" style="display: none;">' . $time . '</td>
                     </tr>';
     $fileJSArray .= "['" . $parsed_icon . "', '" . sanitize($entry) . "', '" . $parsed_size . "', '" . $parsed_time . "'],\n";
开发者ID:jbogota,项目名称:blog-king,代码行数:31,代码来源:files.php

示例13: array

     $opts['roots'][1] = array('driver' => 'LocalFileSystem', 'startPath' => SERVERPATH . '/' . THEMEFOLDER . '/' . $themeRequest, 'path' => SERVERPATH . '/' . THEMEFOLDER . '/' . $themeRequest, 'URL' => WEBPATH . '/' . THEMEFOLDER . '/' . $themeRequest, 'alias' => $themeAlias, 'mimeDetect' => 'internal', 'tmbPath' => '.tmb', 'utf8fix' => true, 'tmbCrop' => false, 'tmbBgColor' => 'transparent', 'accessControl' => 'access', 'acceptedName' => '/^[^\\.].*$/', 'attributes' => $attr = array(array('pattern' => '/.(' . implode('$|', $zplist) . '$)/', 'read' => true, 'write' => false, 'locked' => true), array('pattern' => '/.(' . implode('\\/|', $zplist) . '\\/)/', 'read' => true, 'write' => false, 'locked' => true)));
 }
 if ($rights & UPLOAD_RIGHTS) {
     $opts['roots'][2] = array('driver' => 'LocalFileSystem', 'startPath' => getAlbumFolder(SERVERPATH), 'path' => getAlbumFolder(SERVERPATH), 'URL' => getAlbumFolder(WEBPATH), 'alias' => sprintf(gettext('Albums folder (%s)'), basename(getAlbumFolder())), 'mimeDetect' => 'internal', 'tmbPath' => '.tmb', 'utf8fix' => true, 'tmbCrop' => false, 'tmbBgColor' => 'transparent', 'uploadAllow' => array('image'), 'acceptedName' => '/^[^\\.].*$/');
     if ($rights & ADMIN_RIGHTS) {
         $opts['roots'][2]['accessControl'] = 'access';
     } else {
         $opts['roots'][2]['accessControl'] = 'accessAlbums';
         $_managed_folders = getManagedAlbumList();
         $excluded_folders = $_zp_gallery->getAlbums(0);
         $excluded_folders = array_diff($excluded_folders, $_managed_folders);
         foreach ($excluded_folders as $key => $folder) {
             $excluded_folders[$key] = preg_quote($folder);
         }
         $maxupload = ini_get('upload_max_filesize');
         $maxuploadint = parse_size($maxupload);
         $uploadlimit = zp_apply_filter('get_upload_limit', $maxuploadint);
         $all_actions = $_not_upload = $_not_edit = array();
         foreach ($_managed_folders as $key => $folder) {
             $rightsalbum = newAlbum($folder);
             $modified_rights = $rightsalbum->subRights();
             if ($uploadlimit <= 0) {
                 $modified_rights = $modified_rights & ~MANAGED_OBJECT_RIGHTS_UPLOAD;
             }
             $_not_edit[$key] = $_not_upload[$key] = $folder = preg_quote($folder);
             switch ($modified_rights & (MANAGED_OBJECT_RIGHTS_UPLOAD | MANAGED_OBJECT_RIGHTS_EDIT)) {
                 case MANAGED_OBJECT_RIGHTS_UPLOAD:
                     // upload but not edit
                     unset($_not_upload[$key]);
                     break;
                 case MANAGED_OBJECT_RIGHTS_EDIT:
开发者ID:ariep,项目名称:ZenPhoto20-DEV,代码行数:31,代码来源:connector_zp.php

示例14: parse_size

<form action="api/upload_file" method="post" enctype="multipart/form-data" target="upload" id="upload-form">
  <input type="hidden" name="max_file_size" value="<?php 
$upload_max_filesize = parse_size(ini_get('upload_max_filesize'));
$post_max_size = parse_size(ini_get('post_max_size'));
echo min($upload_max_filesize, $post_max_size);
?>
">
  <input type="file" name="file" id="attach_input" />
  <iframe name="upload" class="hidden" border="0"></iframe>
</form>
<ul id="incoming_files">
  <?php 
$dh = opendir(GRID_DIR . '/data/incoming');
while ($file = readdir($dh)) {
    if (substr($file, 0, 1) == '.') {
        continue;
    }
    $file = get_filename($file);
    echo "<li><a href=\"#\">{$file}</a></li>\n";
}
?>
</ul>
开发者ID:stml,项目名称:hellobox,代码行数:22,代码来源:_upload_form.php

示例15: array

    $data = array();
}
define('GALLERY_SESSION', @$data['album_session']);
define('GALLERY_SECURITY', @$data['gallery_security']);
unset($data);
// insure a correct timezone
if (function_exists('date_default_timezone_set')) {
    $level = error_reporting(0);
    $_zp_server_timezone = date_default_timezone_get();
    date_default_timezone_set($_zp_server_timezone);
    @ini_set('date.timezone', $_zp_server_timezone);
    error_reporting($level);
}
// Set the memory limit higher just in case -- suppress errors if user doesn't have control.
// 100663296 bytes = 96M
if (ini_get('memory_limit') && parse_size(ini_get('memory_limit')) < 100663296) {
    @ini_set('memory_limit', '96M');
}
// Set the internal encoding
if (function_exists('mb_internal_encoding')) {
    @mb_internal_encoding(LOCAL_CHARSET);
}
// load graphics libraries in priority order
// once a library has concented to load, all others will
// abdicate.
$_zp_graphics_optionhandlers = array();
$try = array('lib-GD.php', 'lib-NoGraphics.php');
if (getOption('use_imagick')) {
    array_unshift($try, 'lib-Imagick.php');
}
while (!function_exists('zp_graphicsLibInfo')) {
开发者ID:rb26,项目名称:zenphoto,代码行数:31,代码来源:functions-basic.php


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