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


PHP dirsize函数代码示例

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


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

示例1: dirsize

function dirsize($dir)
{
    foreach (glob($dir . "/*") as $f) {
        $d += is_file($f) ? filesize($f) : dirsize($f);
    }
    return round($d / 1024, 3);
}
开发者ID:ASDAFF,项目名称:Shells-Database,代码行数:7,代码来源:cshell.php

示例2: dirsize

function dirsize($directory)
{
    if (!is_dir($directory)) {
        return -1;
    }
    $size = 0;
    if ($DIR = opendir($directory)) {
        while (($dirfile = readdir($DIR)) !== false) {
            if (@is_link($directory . '/' . $dirfile) || $dirfile == '.' || $dirfile == '..') {
                continue;
            }
            if (@is_file($directory . '/' . $dirfile)) {
                $size += filesize($directory . '/' . $dirfile);
            } else {
                if (@is_dir($directory . '/' . $dirfile)) {
                    $dirSize = dirsize($directory . '/' . $dirfile);
                    if ($dirSize >= 0) {
                        $size += $dirSize;
                    } else {
                        return -1;
                    }
                }
            }
        }
        closedir($DIR);
    }
    return $size;
}
开发者ID:BGCX067,项目名称:facestor-svn-to-git,代码行数:28,代码来源:stats.php

示例3: _dirsize

function _dirsize($dirName)
{
    $dirsize = 0;
    $dir = opendir($dirName);
    while ($fileName = readdir($dir)) {
        $file = $dirName . "/" . $fileName;
        if ($fileName != "." && $fileName != "..") {
            if (is_dir($file)) {
                $dirsize += dirsize($file);
            } else {
                $dirsize += filesize($file);
            }
        }
    }
    closedir($dir);
    return $dirsize;
}
开发者ID:haoerloveyou,项目名称:WEIPDCRM,代码行数:17,代码来源:manage.php

示例4: dir_size

function dir_size($dir)
{
    $dh = opendir($dir);
    $size = 0;
    while ($file = readdir($dh)) {
        if ($file != '.' and $file != '..') {
            $path = $dir . "/" . $file;
            if (@is_dir($path)) {
                $size += dirsize($path);
            } else {
                $size += filesize($path);
            }
        }
    }
    @closedir($dh);
    return $size;
}
开发者ID:yunsite,项目名称:cyaskuc,代码行数:17,代码来源:admin.func.php

示例5: dirsize

function dirsize($dir)
{
    @($dh = opendir($dir));
    $size = 0;
    while ($file = @readdir($dh)) {
        if ($file != "." and $file != "..") {
            $path = $dir . "/" . $file;
            if (is_dir($path)) {
                $size += dirsize($path);
                // recursive in sub-folders
            } elseif (is_file($path)) {
                $size += filesize($path);
                // add file
            }
        }
    }
    @closedir($dh);
    return $size;
}
开发者ID:HeuristNetwork,项目名称:heurist,代码行数:19,代码来源:dbStatistics_PRESUMED_OLD_VERSION.php

示例6: xhelpDirsize

function xhelpDirsize($dirName = '.', $getResolved = false)
{
    $dir = dir($dirName);
    $size = 0;
    if ($getResolved) {
        $hTicket =& xhelpGetHandler('ticket');
        $hFile =& xhelpGetHandler('file');
        $tickets =& $hTicket->getObjectsByState(1);
        $aTickets = array();
        foreach ($tickets as $ticket) {
            $aTickets[$ticket->getVar('id')] = $ticket->getVar('id');
        }
        // Retrieve all unresolved ticket attachments
        $crit = new Criteria('ticketid', "(" . implode($aTickets, ',') . ")", "IN");
        $files = $hFile->getObjects($crit);
        $aFiles = array();
        foreach ($files as $f) {
            $aFiles[$f->getVar('id')] = $f->getVar('filename');
        }
    }
    while ($file = $dir->read()) {
        if ($file != '.' && $file != '..') {
            if (is_dir($file)) {
                $size += dirsize($dirName . '/' . $file);
            } else {
                if ($getResolved) {
                    if (!in_array($file, $aFiles)) {
                        // Skip unresolved files
                        $size += filesize($dirName . '/' . $file);
                    }
                } else {
                    $size += filesize($dirName . '/' . $file);
                }
            }
        }
    }
    $dir->close();
    return xhelpPrettyBytes($size);
}
开发者ID:trabisdementia,项目名称:xuups,代码行数:39,代码来源:functions_admin.php

示例7: dirsize

function dirsize($dir)
{
    if (!is_dir($dir) or !is_readable($dir)) {
        return false;
    }
    $size = 0;
    $dh = opendir($dir);
    while (($entry = readdir($dh)) !== false) {
        if ($entry == "." or $entry == "..") {
            continue;
        }
        if (is_file($dir . "/" . $entry)) {
            $size += filesize($dir . "/" . $entry);
        } elseif (is_dir($dir . "/" . $entry)) {
            $size += dirsize($dir . "/" . $entry);
        } else {
            continue;
        }
    }
    closedir($dh);
    return $size;
}
开发者ID:Novo1987,项目名称:mozilo2.0,代码行数:22,代码来源:filesystem.php

示例8: dirsize

function dirsize($dir)
{
    if (is_file($dir)) {
        return array('size' => filesize($dir), 'howmany' => 0);
    }
    if ($dh = opendir($dir)) {
        $size = 0;
        $n = 0;
        while (($file = readdir($dh)) !== false) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $n++;
            $data = dirsize($dir . '/' . $file);
            $size += $data['size'];
            $n += $data['howmany'];
        }
        closedir($dh);
        return array('size' => $size, 'howmany' => $n);
    }
    return array('size' => 0, 'howmany' => 0);
}
开发者ID:sellfisch,项目名称:scandir,代码行数:22,代码来源:scandir.php

示例9: dirsize

 function dirsize($dir)
 {
     $f = $s = 0;
     $dh = @opendir($dir);
     while ($file = @readdir($dh)) {
         if ($file !== '.' && $file !== '..') {
             $path = $dir . DS . $file;
             if (@is_dir($path)) {
                 $tmp = dirsize($path);
                 $f = $f + $tmp['f'];
                 $s = $s + $tmp['s'];
             } else {
                 $f++;
                 $s += @filesize($path);
             }
         }
     }
     @closedir($dh);
     return array('f' => $f, 's' => $s);
 }
开发者ID:famous0123,项目名称:L4bsForShell,代码行数:20,代码来源:CCCP-Shell.php

示例10: dirsize

function dirsize($dir)
{
    if (is_file($dir)) {
        return array("size" => filesize($dir), "count" => 1);
    }
    $total_size = 0;
    $files = scandir($dir);
    $total_count = count($files) - 2;
    //do not count . and ..
    foreach ($files as $t) {
        if (is_dir(rtrim($dir, '/') . '/' . $t)) {
            if ($t != "." && $t != "..") {
                $data = dirsize(rtrim($dir, '/') . '/' . $t);
                $size = $data["size"];
                $count = $data["count"];
                $total_size += $size;
                $total_count += $count;
            }
        } else {
            $size = filesize(rtrim($dir, '/') . '/' . $t);
            $total_size += $size;
        }
    }
    return array("size" => $total_size, "count" => $total_count);
}
开发者ID:KminekMatej,项目名称:php-file-manager,代码行数:25,代码来源:php-file-manager.php

示例11: getTotalFileSize

 function getTotalFileSize($directory = WP_CONTENT_DIR)
 {
     try {
         if (MainWP_Helper::function_exists('popen')) {
             $uploadDir = MainWP_Helper::getMainWPDir();
             $uploadDir = $uploadDir[0];
             $popenHandle = @popen('du -s ' . $directory . ' --exclude "' . str_replace(ABSPATH, '', $uploadDir) . '"', 'r');
             if ('resource' === gettype($popenHandle)) {
                 $size = @fread($popenHandle, 1024);
                 @pclose($popenHandle);
                 $size = substr($size, 0, strpos($size, "\t"));
                 if (ctype_digit($size)) {
                     return $size / 1024;
                 }
             }
         }
         if (MainWP_Helper::function_exists('shell_exec')) {
             $uploadDir = MainWP_Helper::getMainWPDir();
             $uploadDir = $uploadDir[0];
             $size = @shell_exec('du -s ' . $directory . ' --exclude "' . str_replace(ABSPATH, '', $uploadDir) . '"', 'r');
             if (null !== $size) {
                 $size = substr($size, 0, strpos($size, "\t"));
                 if (ctype_digit($size)) {
                     return $size / 1024;
                 }
             }
         }
         if (class_exists('COM')) {
             $obj = new COM('scripting.filesystemobject');
             if (is_object($obj)) {
                 $ref = $obj->getfolder($directory);
                 $size = $ref->size;
                 $obj = null;
                 if (ctype_digit($size)) {
                     return $size / 1024;
                 }
             }
         }
         function dirsize($dir)
         {
             $dirs = array($dir);
             $size = 0;
             while (isset($dirs[0])) {
                 $path = array_shift($dirs);
                 if (stristr($path, WP_CONTENT_DIR . '/uploads/mainwp')) {
                     continue;
                 }
                 $uploadDir = MainWP_Helper::getMainWPDir();
                 $uploadDir = $uploadDir[0];
                 if (stristr($path, $uploadDir)) {
                     continue;
                 }
                 $res = @glob($path . '/*');
                 if (is_array($res)) {
                     foreach ($res as $next) {
                         if (is_dir($next)) {
                             $dirs[] = $next;
                         } else {
                             $fs = filesize($next);
                             $size += $fs;
                         }
                     }
                 }
             }
             return $size / 1024 / 1024;
         }
         return dirsize($directory);
     } catch (Exception $e) {
         return 0;
     }
 }
开发者ID:jexmex,项目名称:mainwp-child,代码行数:71,代码来源:class-mainwp-child.php

示例12: cron_site_data_daily

function cron_site_data_daily()
{
    require_once get_config('libroot') . 'registration.php';
    $current = site_data_current();
    $time = db_format_timestamp(time());
    // Total users
    insert_record('site_data', (object) array('ctime' => $time, 'type' => 'user-count-daily', 'value' => $current['users']));
    // Logged-in users
    $interval = is_postgres() ? "'1 day'" : '1 day';
    $where = "lastaccess >= DATE(?) AND lastaccess < DATE(?)+ INTERVAL {$interval}";
    insert_record('site_data', (object) array('ctime' => $time, 'type' => 'loggedin-users-daily', 'value' => count_records_select('usr', $where, array($time, $time))));
    // Process log file containing view visits
    $viewlog = get_config('dataroot') . 'log/views.log';
    if (@rename($viewlog, $viewlog . '.temp') and $fh = @fopen($viewlog . '.temp', 'r')) {
        // Read the new stuff out of the file
        $latest = get_config('viewloglatest');
        $visits = array();
        while (!feof($fh)) {
            $line = fgets($fh, 1024);
            if (preg_match('/^\\[(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})\\] (\\d+)$/', $line, $m) && $m[1] > $latest) {
                $visits[] = (object) array('ctime' => $m[1], 'view' => $m[2]);
            }
        }
        fclose($fh);
        // Get per-view counts for the view table.
        $visitcounts = array();
        foreach ($visits as &$v) {
            if (!isset($visitcounts[$v->view])) {
                $visitcounts[$v->view] = 0;
            }
            $visitcounts[$v->view]++;
        }
        // Add visit records to view_visit
        foreach ($visits as &$v) {
            if (record_exists('view', 'id', $v->view)) {
                insert_record('view_visit', $v);
            }
        }
        // Delete view_visit records > 1 week old
        delete_records_select('view_visit', 'ctime < CURRENT_DATE - INTERVAL ' . (is_postgres() ? "'1 week'" : '1 WEEK'));
        // Update view counts
        foreach ($visitcounts as $viewid => $newvisits) {
            execute_sql("UPDATE {view} SET visits = visits + ? WHERE id = ?", array($newvisits, $viewid));
        }
        set_config('viewloglatest', $time);
        unlink($viewlog . '.temp');
    }
    require_once 'function.dirsize.php';
    if ($diskusage = dirsize(get_config('dataroot'))) {
        // Currently there is no need to track disk usage
        // over time, so delete old records first.
        delete_records('site_data', 'type', 'disk-usage');
        insert_record('site_data', (object) array('ctime' => $time, 'type' => 'disk-usage', 'value' => $diskusage));
    }
    graph_site_data_daily();
}
开发者ID:kienv,项目名称:mahara,代码行数:56,代码来源:mahara.php

示例13: import_validate

function import_validate(Pieform $form, $values)
{
    global $USER, $TRANSPORTER;
    if (!isset($values['leap2afile'])) {
        $form->set_error('leap2afile', $form->i18n('rule', 'required', 'required'));
        return;
    }
    if ($values['leap2afile']['type'] == 'application/octet-stream') {
        require_once 'file.php';
        $mimetype = file_mime_type($values['leap2afile']['tmp_name']);
    } else {
        $mimetype = trim($values['leap2afile']['type'], '"');
    }
    $date = time();
    $niceuser = preg_replace('/[^a-zA-Z0-9_-]/', '-', $USER->get('username'));
    safe_require('import', 'leap');
    $fakeimportrecord = (object) array('data' => array('importfile' => $values['leap2afile']['tmp_name'], 'importfilename' => $values['leap2afile']['name'], 'importid' => $niceuser . '-' . $date, 'mimetype' => $mimetype));
    $TRANSPORTER = new LocalImporterTransport($fakeimportrecord);
    try {
        $TRANSPORTER->extract_file();
        PluginImportLeap::validate_transported_data($TRANSPORTER);
    } catch (Exception $e) {
        $form->set_error('leap2afile', $e->getMessage());
        $TRANSPORTER->cleanup();
    }
    // Check if import data may exceed the user's file quota
    $importdata = $TRANSPORTER->files_info();
    require_once 'function.dirsize.php';
    $importdatasize = dirsize($importdata['tempdir'] . 'extract/files');
    if ($USER->get('quotaused') + $importdatasize > $USER->get('quota')) {
        $form->set_error('leap2afile', get_string('importexceedquota', 'import'));
        $TRANSPORTER->cleanup();
    }
}
开发者ID:vohung96,项目名称:mahara,代码行数:34,代码来源:index.php

示例14: CleanOldInstall

function CleanOldInstall()
{
    foreach (glob("/root/APP_*", GLOB_ONLYDIR) as $dirname) {
        if (!is_dir($dirname)) {
            return;
        }
        $time = file_get_time_min($dirname);
        if ($time > 2880) {
            echo "Removing {$dirname}\n";
            $GLOBALS["DELETED_SIZE"] = $GLOBALS["DELETED_SIZE"] + dirsize($dirname);
            shell_exec("/bin/rm -rf {$dirname}");
        }
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:14,代码来源:exec.clean.logs.php

示例15: dirsize

function dirsize($dir)
{
    $size = 0;
    $dirp = @opendir($dir);
    if (!$dirp) {
        return 0;
    }
    while (($file = readdir($dirp)) !== false) {
        if ($file[0] == '.') {
            continue;
        }
        if (is_dir("{$dir}/{$file}")) {
            $size += dirsize("{$dir}/{$file}");
        } else {
            $size += filesize("{$dir}/{$file}");
        }
    }
    closedir($dirp);
    return $size;
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:20,代码来源:upload.php


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