本文整理汇总了PHP中dirSize函数的典型用法代码示例。如果您正苦于以下问题:PHP dirSize函数的具体用法?PHP dirSize怎么用?PHP dirSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dirSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirSize
/**
* Created by PhpStorm.
* User: Administrator
* Date: 15-7-11
* Time: 上午10:26
*/
function dirSize($directory)
{
$dir_size = 0;
//累加各种文件大小
if ($dir_handle = @opendir($directory)) {
//打开目录,,并判断是否能成功打开,@使用不显示错误。
while ($filename = readdir($dir_handle)) {
//循环遍历目录下的所有文件
if ($filename != "." && $filename != "..") {
//排除两个特殊的目录
$subFile = $directory . "/" . $filename;
//将目录下的子文件和当前目录相连
if (is_dir($subFile)) {
//如果子文件是目录,则递归
$dir_size += dirSize($subFile);
}
if (is_file($subFile)) {
// 如果是文件,则直接计算filesize大小并累加
$dir_size += filesize($subFile);
}
}
}
closedir($dir_handle);
//最后一定要记得关闭文件句柄
return $dir_size;
//返回输入目录的大小,单位是byte
}
}
示例2: getServerFiles
private function getServerFiles($serversList, $id)
{
$res = array();
$tasksData = $serversList->data[$id]['tasks'];
foreach (glob(__archiveDIR . "servers/{$id}/*") as $path) {
$name = 'Undefined';
$subId = str_replace(__archiveDIR . "servers/{$id}/", '', $path);
if (isset($tasksData[$subId])) {
$name = $tasksData[$subId]['title'];
}
$res[] = array('id' => $subId, 'name' => $name, 'size' => dirSize($path), 'time' => filectime($path), 'filesCount' => count(glob($path . "/*")));
}
return $res;
}
示例3: getLocalFolder
private function getLocalFolder()
{
$res = array();
$tasksList = new JsonDB(__taskdb);
foreach (glob(__archiveDIR . 'local/*') as $path) {
if (is_dir($path)) {
$id = str_replace(__archiveDIR . 'local/', '', $path);
$name = 'Undefined';
if (isset($tasksList->data[$id])) {
$name = $tasksList->data[$id]['title'];
}
$res[$id] = array('id' => $id, 'name' => $name, 'size' => dirSize($path), 'time' => filectime($path), 'filesCount' => count(glob($path . "/*")));
}
}
return $res;
}
示例4: dirSize
/**
* 递归获取文件夹大小
* @param $path
* @return int
*/
function dirSize($path)
{
$sum = 0;
//global $sum;
$handle = opendir($path);
while (($item = readdir($handle)) !== false) {
if ($item != '.' && $item != '..') {
if (is_file($path . '/' . $item)) {
$sum += filesize($path . '/' . $item);
}
if (is_dir($path . '/' . $item)) {
/*$func = __FUNCTION__;
$func($path.'/'.$item);*/
$sum += dirSize($path . '/' . $item);
//递归获取文件夹的大小
}
}
}
closedir($handle);
return $sum;
}
示例5:
<link href="../../../etc/styles/<?php
echo $currentuser['usertheme'];
?>
/css/<?php
echo $currentuser['usercss'];
?>
.css" rel="stylesheet" type="text/css">
<script src="../assets/ajaxsbmt.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<body style="background: #F3F3F3;">
<div style="margin-left:20px;margin-right:20px;">
<div class="zform_wrapper">
<h2>Backup your hosting account files</h2>
<p>Your data is ready to be backed up. This proccess can take a lot of time, depending on your directory size. When finished you will be prompted to download your archive.</p>
<p>Current public directory size: <b><?php
echo fs_director::ShowHumanFileSize(dirSize(ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/public_html"));
?>
</b></p>
<div id="BackupSubmit" style="height:100%;margin:auto;">
<form name="doBackup" action="response_normal.php" method="post" onsubmit="xmlhttpPost('dobackup.php?id=<?php
echo $userid;
?>
', 'doBackup', 'BackupResult', 'Compressing your data, please wait...<br><img src=\'../assets/bar.gif\'>'); return false;">
<table class="zform">
<tr valign="top">
<th nowrap="nowrap"><button class="fg-button ui-state-default ui-corner-all" id="SubmitBackup" type="submit" name="inBackUp" value="">Backup Now</button></th>
<td><input type="hidden" name="inDownLoad" id="inDownLoad" value="1" /></td>
</tr>
</table>
</form>
</div>
示例6: transByte
?>
<!-- 读取目录的操作-->
<?php
if($info['dir']){
$i=$i==null?1:$i;
foreach($info['dir'] as $val){
$p=$path."/".$val;
?>
<tr>
<td><?php echo $i;?></td>
<td><?php echo $val;?></td>
<td><?php $src=filetype($p)=="file"?"file_ico.png":"folder_ico.png";?><img src="images/<?php echo $src;?>" alt="" title="文件"/></td>
<td><?php $sum=0; echo transByte(dirSize($p));?></td>
<td><?php $src=is_readable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php $src=is_writable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php $src=is_executable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php echo date("Y-m-d H:i:s",filectime($p));?></td>
<td><?php echo date("Y-m-d H:i:s",filemtime($p));?></td>
<td><?php echo date("Y-m-d H:i:s",fileatime($p));?></td>
<td>
<a href="index.php?path=<?php echo $p;?>" ><img class="small" src="images/show.png" alt="" title="查看"/></a>|
<a href="index.php?act=renameFolder&path=<?php echo $path;?>&dirname=<?php echo $p;?>"><img class="small" src="images/rename.png" alt="" title="重命名"/></a>|
<a href="index.php?act=copyFolder&path=<?php echo $path;?>&dirname=<?php echo $p;?>"><img class="small" src="images/copy.png" alt="" title="复制"/></a>|
<a href="index.php?act=cutFolder&path=<?php echo $path;?>&dirname=<?php echo $p;?>"><img class="small" src="images/cut.png" alt="" title="剪切"/></a>|
<a href="#" onclick="delFolder('<?php echo $p;?>','<?php echo $path;?>')"><img class="small" src="images/delete.png" alt="" title="删除"/></a>|
</td>
</tr>
<?php
示例7: listar_directorios_ruta
/**
* Rutina encargada de leer los directorios, subdirectorios y archivos de
* una determinada $ruta
* $catalogo: catalogo al que corresponden los archivos
* $ruta: ruta a leer
*/
function listar_directorios_ruta($catalogo, $ruta)
{
header("Content-type: text/html; charset=UTF-8");
// abrir un directorio y listarlo recursivo
if (is_dir($ruta)) {
if ($dh = opendir($ruta)) {
while (($file = readdir($dh)) !== false) {
//esta línea la utilizaríamos si queremos listar todo lo que hay en el directorio
//mostraría tanto archivos como directorios
if ($file != '.' && $file != '..') {
include "conn.php";
//conexion a postgresql
$conn = pg_connect("host={$dbhost} port={$dbport} dbname={$dbname} user={$dbuser} password={$dbpass}") or die('<div width="100%" class="error">OCURRIO UN ERROR AL INTENTAR CONECTAR A LA BASE DE DATOS <B>' . $dbname . ' </B></div>');
$filetype = filetype($ruta . $file);
switch ($filetype) {
case 'dir':
$extension = 'dir';
$size = sprintf("%u", dirSize($ruta . $file));
break;
//Obteniendo la extension del archivo
//Obteniendo la extension del archivo
default:
//try{
$extension = strtolower(substr(strrchr($ruta . $file, "."), 1));
//Lee correctamente archivos mayores a 4GB
$size = GetRealSize($ruta . $file);
break;
}
$file_temp = strtolower(limpia($file));
$ruta_temp = strtolower(limpia($ruta));
//String para ingresar el archivo
$query = "insert into archivo values('{$catalogo}','{$file_temp}','{$size}','{$extension}','{$ruta_temp}');";
if ($debug) {
echo $query . "<br>";
}
//Ingresando el archivo
$result = pg_query($conn, $query);
if (!$result) {
mensaje("Nombre Archivo: " . $file_temp, pg_last_error($conn));
}
pg_close($conn);
}
//if para saber si el elemento es un directorio
if (is_dir($ruta . $file) && $file != "." && $file != "..") {
//solo si el archivo es un directorio, distinto que "." y ".."
//echo "<br>Directorio: $ruta$file";
listar_directorios_ruta($catalogo, $ruta . $file . "/");
}
}
closedir($dh);
}
} else {
echo "<br>No es ruta valida" + $ruta;
}
}
示例8: getSize
function getSize($dirFile, $mode = 'file')
{
if ('file' == $mode) {
$stats = stat($dirFile);
} elseif ('dir' == $mode) {
$stats['size'] = dirSize($dirFile);
}
if (empty($stats['size'])) {
$stats['_size'] = '';
} elseif ($stats['size'] < 1024) {
$stats['_size'] .= ' B';
} elseif ($stats['size'] < 1048576) {
$stats['_size'] = round($stats['size'] / 1024) . ' KB';
} else {
$stats['_size'] = round($stats['size'] / 1048576, 2) . ' MB';
}
return $stats;
}
示例9: filetype
?>
</td>
<td><?php
echo $val;
?>
</td>
<td><?php
$src = filetype($p) == "file" ? "file_ico.png" : "folder_ico.png";
?>
<img src="images/<?php
echo $src;
?>
" alt="" title="文件"/></td>
<td><?php
$sum = 0;
echo transByte(dirSize($p));
?>
</td>
<td><?php
$src = is_readable($p) ? "correct.png" : "error.png";
?>
<img class="small" src="images/<?php
echo $src;
?>
" alt=""/></td>
<td><?php
$src = is_writable($p) ? "correct.png" : "error.png";
?>
<img class="small" src="images/<?php
echo $src;
?>
示例10: dirSize
<?php
//Testing
//$dir= "sample/4mh11me";
//Production
$clg = $_POST["clg"];
$code = $_POST["code"];
$year = $_POST["year"];
$branch = $_POST["branch"];
$dir = "sample/" . $clg . $code . $year . $branch;
function dirSize($directory)
{
$size = 0;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
$size += $file->getSize();
}
return round($size / 1024) . " kb";
}
$fi = new FilesystemIterator($dir, FilesystemIterator::SKIP_DOTS);
$arr = array('fileN' => iterator_count($fi), 'size' => dirSize($dir));
echo json_encode($arr);
示例11: getLocalList
<div class="moduleContent" align=left>
<?php
$localModules = getLocalList();
if ($localModules[0] == "") {
echo "<center>" . $strings["modules-installed-noModules"] . "</center>";
} else {
#$usbPresent = (exec("mount | grep \"on /usb\" -c") >= 1)?true:false;
$usbModules = false;
$moduleArray = array();
foreach ($localModules as $module) {
$usbModules = false;
$module = explode("|", $module);
if ($module[2] == "internal") {
$size = dirSize("/pineapple/infusions/" . $module[0]);
} else {
$size = dirSize("/pineapple/infusions/usbInfusions/" . $module[0]);
}
if ($module[4] == "") {
$supportLink = "";
} else {
$supportLink = "<a href=\"" . $module[4] . "\" target=\"_blank\">" . $strings["modules-links-supportLink"] . "</a>";
}
if (isPinned($module[0], $module[2], $module[3])) {
$pinLink = "<a href='index.php?modules&unpin={$module['0']}'>" . $strings["modules-links-unpin"] . "</a>";
} else {
$pinLink = "<a href='index.php?modules&pin={$module['0']}&dest={$module['2']}&startPage={$module['3']}'>" . $strings["modules-links-pin"] . "</a>";
}
if ($module[2] == "internal") {
$launchLink = "<a href='/infusions/" . $module[0] . "/" . $module[3] . "'>" . $module[0] . "</a>";
} else {
$usbModules = true;
示例12: getServerInfo
function getServerInfo()
{
$tasks = new JsonDB($this->taskdb);
$result = $this->settings;
unset($result['apiKey']);
$result['serverSoftware'] = $_SERVER['SERVER_SOFTWARE'];
$result['documentRoot'] = $_SERVER['DOCUMENT_ROOT'];
$result['freeSpace'] = disk_free_space(getcwd());
$result['tasksCount'] = count($tasks->data);
$tasks = $tasks->data;
foreach ($tasks as $key => $task) {
$tasks[$key]['memoryUsage'] = dirSize(__archiveDIR . 'local/' . $task['id']);
}
$result['tasks'] = $tasks;
$result['responseStatus'] = 'ok';
return $result;
}
示例13: getMemoryUsage
function getMemoryUsage($task)
{
if (!is_dir(__archiveDIR . 'local/' . $task['id'])) {
return 0;
}
return memoryFormat(dirSize(__archiveDIR . 'local/' . $task['id']));
}
示例14: getDirSize
function getDirSize($params)
{
global $fileDir;
if (isset($params["directory"])) {
$size = dirSize($fileDir . $params["directory"]) * 1024;
sendSuccess($size);
} else {
sendFailed("Directory is not specified");
}
}
示例15: filetype
echo $val;
?>
</td><!--名称-->
<td><!--类型-->
<?php
$src = filetype($paths) == 'file' ? 'file_ico.png' : 'folder_ico.png';
?>
<img src="images/<?php
echo $src;
?>
" alt="" width="32" height="32"/>
</td>
<td><!--大小-->
<?php
$sum = 0;
echo transByte(dirSize($paths));
//获取文件夹大小
?>
</td>
<td><!--可读-->
<?php
$is_read = is_readable($paths);
if ($is_read) {
echo '<img src="images/correct.png?>" alt="" width="32" height="32"/>';
} else {
echo '<img src="images/ban.png?>" alt="" width="32" height="32"/>';
}
?>
</td>
<td><!--可写-->
<?php