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


PHP get_directory_size函数代码示例

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


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

示例1: __construct

 public function __construct($path = SEARCH_INDEX_PATH)
 {
     global $CFG, $db;
     $this->path = $path;
     //test to see if there is a valid index on disk, at the specified path
     try {
         $test_index = new Zend_Search_Lucene($this->path, false);
         $validindex = true;
     } catch (Exception $e) {
         $validindex = false;
     }
     //retrieve file system info about the index if it is valid
     if ($validindex) {
         $this->size = display_size(get_directory_size($this->path));
         $index_dir = get_directory_list($this->path, '', false, false);
         $this->filecount = count($index_dir);
         $this->indexcount = $test_index->count();
     } else {
         $this->size = 0;
         $this->filecount = 0;
         $this->indexcount = 0;
     }
     $db_exists = false;
     //for now
     //get all the current tables in moodle
     $admin_tables = $db->MetaTables();
     //TODO: use new IndexDBControl class for database checks?
     //check if our search table exists
     if (in_array($CFG->prefix . SEARCH_DATABASE_TABLE, $admin_tables)) {
         //retrieve database information if it does
         $db_exists = true;
         //total documents
         $this->dbcount = count_records(SEARCH_DATABASE_TABLE);
         //individual document types
         // $types = search_get_document_types();
         $types = search_collect_searchables(true, false);
         sort($types);
         foreach ($types as $type) {
             $c = count_records(SEARCH_DATABASE_TABLE, 'doctype', $type);
             $this->types[$type] = (int) $c;
         }
     } else {
         $this->dbcount = 0;
         $this->types = array();
     }
     //check if the busy flag is set
     if (isset($CFG->search_indexer_busy) && $CFG->search_indexer_busy == '1') {
         $this->complete = false;
     } else {
         $this->complete = true;
     }
     //get the last run date for the indexer
     if ($this->valid() && $CFG->search_indexer_run_date) {
         $this->time = $CFG->search_indexer_run_date;
     } else {
         $this->time = 0;
     }
 }
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:58,代码来源:indexlib.php

示例2: run

 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('filedump')) {
         return new ocp_tempcode();
     }
     if (!file_exists(get_custom_file_base() . '/uploads/filedump')) {
         return new ocp_tempcode();
     }
     require_lang('filedump');
     require_code('files2');
     $bits = new ocp_tempcode();
     if (get_option('filedump_show_stats_count_total_files', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('COUNT_FILES'), 'VALUE' => integer_format(count(get_directory_contents(get_custom_file_base() . '/uploads/filedump'))))));
     }
     if (get_option('filedump_show_stats_count_total_space', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('DISK_USAGE'), 'VALUE' => clean_file_size(get_directory_size(get_custom_file_base() . '/uploads/filedump')))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $section = do_template('BLOCK_SIDE_STATS_SECTION', array('SECTION' => do_lang_tempcode('FILE_DUMP'), 'CONTENT' => $bits));
     return $section;
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:28,代码来源:stats_filedump.php

示例3: get_directory_size

/**
 * Adds up all the files in a directory and works out the size.
 *
 * @param string $rootdir  The directory to start from
 * @param string $excludefile A file to exclude when summing directory size
 * @return int The summed size of all files and subfiles within the root directory
 */
function get_directory_size($rootdir, $excludefile = '')
{
    global $CFG;
    // Do it this way if we can, it's much faster.
    if (!empty($CFG->pathtodu) && is_executable(trim($CFG->pathtodu))) {
        $command = trim($CFG->pathtodu) . ' -sk ' . escapeshellarg($rootdir);
        $output = null;
        $return = null;
        exec($command, $output, $return);
        if (is_array($output)) {
            // We told it to return k.
            return get_real_size(intval($output[0]) . 'k');
        }
    }
    if (!is_dir($rootdir)) {
        // Must be a directory.
        return 0;
    }
    if (!($dir = @opendir($rootdir))) {
        // Can't open it for some reason.
        return 0;
    }
    $size = 0;
    while (false !== ($file = readdir($dir))) {
        $firstchar = substr($file, 0, 1);
        if ($firstchar == '.' or $file == 'CVS' or $file == $excludefile) {
            continue;
        }
        $fullfile = $rootdir . '/' . $file;
        if (filetype($fullfile) == 'dir') {
            $size += get_directory_size($fullfile, $excludefile);
        } else {
            $size += filesize($fullfile);
        }
    }
    closedir($dir);
    return $size;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:45,代码来源:moodlelib.php

示例4: displaydir

function displaydir($wdir)
{
    //  $wdir == / or /a or /a/b/c/d  etc
    global $basedir;
    global $id;
    global $USER, $CFG;
    global $choose;
    $fullpath = $basedir . $wdir;
    $dirlist = array();
    $directory = opendir($fullpath);
    // Find all files
    while (false !== ($file = readdir($directory))) {
        if ($file == "." || $file == "..") {
            continue;
        }
        if (is_dir($fullpath . "/" . $file)) {
            $dirlist[] = $file;
        } else {
            $filelist[] = $file;
        }
    }
    closedir($directory);
    $strname = get_string("name");
    $strsize = get_string("size");
    $strmodified = get_string("modified");
    $straction = get_string("action");
    $strmakeafolder = get_string("makeafolder");
    $struploadafile = get_string("uploadafile");
    $strselectall = get_string("selectall");
    $strselectnone = get_string("deselectall");
    $strwithchosenfiles = get_string("withchosenfiles");
    $strmovetoanotherfolder = get_string("movetoanotherfolder");
    $strmovefilestohere = get_string("movefilestohere");
    $strdeletecompletely = get_string("deletecompletely");
    $strcreateziparchive = get_string("createziparchive");
    $strrename = get_string("rename");
    $stredit = get_string("edit");
    $strunzip = get_string("unzip");
    $strlist = get_string("list");
    $strrestore = get_string("restore");
    $strchoose = get_string("choose");
    $strfolder = get_string("folder");
    $strfile = get_string("file");
    echo "<form action=\"index.php\" method=\"post\" id=\"dirform\">";
    echo "<div>";
    echo '<input type="hidden" name="choose" value="' . $choose . '" />';
    // echo "<hr align=\"center\" noshade=\"noshade\" size=\"1\" />";
    echo "<hr/>";
    echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\" class=\"files\">";
    echo "<tr>";
    echo "<th class=\"header\" scope=\"col\"></th>";
    echo "<th class=\"header name\" scope=\"col\">{$strname}</th>";
    echo "<th class=\"header size\" scope=\"col\">{$strsize}</th>";
    echo "<th class=\"header date\" scope=\"col\">{$strmodified}</th>";
    echo "<th class=\"header commands\" scope=\"col\">{$straction}</th>";
    echo "</tr>\n";
    if ($wdir != "/") {
        $dirlist[] = '..';
    }
    $count = 0;
    if (!empty($dirlist)) {
        asort($dirlist);
        foreach ($dirlist as $dir) {
            echo "<tr class=\"folder\">";
            if ($dir == '..') {
                $fileurl = rawurlencode(dirname($wdir));
                print_cell();
                // alt attribute intentionally empty to prevent repetition in screen reader
                print_cell('left', '<a href="index.php?id=' . $id . '&amp;wdir=' . $fileurl . '&amp;choose=' . $choose . '"><img src="' . $CFG->pixpath . '/f/parent.gif" class="icon" alt="" />&nbsp;' . get_string('parentfolder') . '</a>', 'name');
                print_cell();
                print_cell();
                print_cell();
            } else {
                $count++;
                $filename = $fullpath . "/" . $dir;
                $fileurl = rawurlencode($wdir . "/" . $dir);
                $filesafe = rawurlencode($dir);
                $filesize = display_size(get_directory_size("{$fullpath}/{$dir}"));
                $filedate = userdate(filemtime($filename), get_string("strftimedatetime"));
                if ($wdir . $dir === '/moddata') {
                    print_cell();
                } else {
                    print_cell("center", "<input type=\"checkbox\" name=\"file{$count}\" value=\"{$fileurl}\" />", 'checkbox');
                }
                print_cell("left", "<a href=\"index.php?id={$id}&amp;wdir={$fileurl}&amp;choose={$choose}\"><img src=\"{$CFG->pixpath}/f/folder.gif\" class=\"icon\" alt=\"{$strfolder}\" />&nbsp;" . htmlspecialchars($dir) . "</a>", 'name');
                print_cell("right", $filesize, 'size');
                print_cell("right", $filedate, 'date');
                if ($wdir . $dir === '/moddata') {
                    print_cell();
                } else {
                    print_cell("right", "<a href=\"index.php?id={$id}&amp;wdir={$wdir}&amp;file={$filesafe}&amp;action=rename&amp;choose={$choose}\">{$strrename}</a>", 'commands');
                }
            }
            echo "</tr>";
        }
    }
    if (!empty($filelist)) {
        asort($filelist);
        foreach ($filelist as $file) {
            $icon = mimeinfo("icon", $file);
//.........这里部分代码省略.........
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:index.php

示例5: display

 function display()
 {
     global $CFG;
     /// Set up generic stuff first, including checking for access
     parent::display();
     /// Set up some shorthand variables
     $cm = $this->cm;
     $course = $this->course;
     $resource = $this->resource;
     require_once $CFG->libdir . '/filelib.php';
     $subdir = optional_param('subdir', '', PARAM_PATH);
     $resource->reference = clean_param($resource->reference, PARAM_PATH);
     $formatoptions = new object();
     $formatoptions->noclean = true;
     $formatoptions->para = false;
     // MDL-12061, <p> in html editor breaks xhtml strict
     add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
     if ($resource->reference) {
         $relativepath = "{$course->id}/{$resource->reference}";
     } else {
         $relativepath = "{$course->id}";
     }
     if ($subdir) {
         $relativepath = "{$relativepath}{$subdir}";
         if (stripos($relativepath, 'backupdata') !== FALSE or stripos($relativepath, $CFG->moddata) !== FALSE) {
             error("Access not allowed!");
         }
         $subs = explode('/', $subdir);
         array_shift($subs);
         $countsubs = count($subs);
         $count = 0;
         $backsub = '';
         foreach ($subs as $sub) {
             $count++;
             if ($count < $countsubs) {
                 $backsub .= "/{$sub}";
                 $this->navlinks[] = array('name' => $sub, 'link' => "view.php?id={$cm->id}", 'type' => 'title');
             } else {
                 $this->navlinks[] = array('name' => $sub, 'link' => '', 'type' => 'title');
             }
         }
     }
     $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
     $update = update_module_button($cm->id, $course->id, $this->strresource);
     if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id))) {
         $options = array('id' => $course->id, 'wdir' => '/' . $resource->reference . $subdir);
         $editfiles = print_single_button("{$CFG->wwwroot}/files/index.php", $options, get_string("editfiles"), 'get', '', true);
         $update = $editfiles . $update;
     }
     $navigation = build_navigation($this->navlinks, $cm);
     print_header($pagetitle, $course->fullname, $navigation, "", "", true, $update, navmenu($course, $cm));
     if (trim(strip_tags($resource->summary))) {
         print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
         print_spacer(10, 10);
     }
     $files = get_directory_list("{$CFG->dataroot}/{$relativepath}", array($CFG->moddata, 'backupdata'), false, true, true);
     if (!$files) {
         print_heading(get_string("nofilesyet"));
         print_footer($course);
         exit;
     }
     print_simple_box_start("center", "", "", '0');
     $strftime = get_string('strftimedatetime');
     $strname = get_string("name");
     $strsize = get_string("size");
     $strmodified = get_string("modified");
     $strfolder = get_string("folder");
     $strfile = get_string("file");
     echo '<table cellpadding="4" cellspacing="1" class="files" summary="">';
     echo "<tr><th class=\"header name\" scope=\"col\">{$strname}</th>" . "<th align=\"right\" colspan=\"2\" class=\"header size\" scope=\"col\">{$strsize}</th>" . "<th align=\"right\" class=\"header date\" scope=\"col\">{$strmodified}</th>" . "</tr>";
     foreach ($files as $file) {
         if (is_dir("{$CFG->dataroot}/{$relativepath}/{$file}")) {
             // Must be a directory
             $icon = "folder.gif";
             $relativeurl = "/view.php?blah";
             $filesize = display_size(get_directory_size("{$CFG->dataroot}/{$relativepath}/{$file}"));
         } else {
             $icon = mimeinfo("icon", $file);
             $relativeurl = get_file_url("{$relativepath}/{$file}");
             $filesize = display_size(filesize("{$CFG->dataroot}/{$relativepath}/{$file}"));
         }
         if ($icon == 'folder.gif') {
             echo '<tr class="folder">';
             echo '<td class="name">';
             echo "<a href=\"view.php?id={$cm->id}&amp;subdir={$subdir}/{$file}\">";
             echo "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"{$strfolder}\" />&nbsp;{$file}</a>";
         } else {
             echo '<tr class="file">';
             echo '<td class="name">';
             link_to_popup_window($relativeurl, "resourcedirectory{$resource->id}", "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"{$strfile}\" />&nbsp;{$file}", 450, 600, '');
         }
         echo '</td>';
         echo '<td>&nbsp;</td>';
         echo '<td align="right" class="size">';
         echo $filesize;
         echo '</td>';
         echo '<td align="right" class="date">';
         echo userdate(filemtime("{$CFG->dataroot}/{$relativepath}/{$file}"), $strftime);
         echo '</td>';
         echo '</tr>';
//.........这里部分代码省略.........
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:101,代码来源:resource.class.php

示例6: repository_get_directory_size

function repository_get_directory_size($rootdir, $excludefile = '')
{
    global $CFG;
    if (($r = repository_is_local($rootdir)) !== false) {
        return get_directory_size($r->local_path($rootdir), $excludefile);
    }
    if (!repository_is_dir($rootdir)) {
        // Must be a directory
        return 0;
    }
    if (!($dir = @opendir($rootdir))) {
        // Can't open it for some reason
        return 0;
    }
    $size = 0;
    while (false !== ($file = readdir($dir))) {
        $firstchar = substr($file, 0, 1);
        if ($firstchar == '.' or $file == 'CVS' or $file == $excludefile) {
            continue;
        }
        $fullfile = $rootdir . '/' . $file;
        if (repository_is_dir($fullfile)) {
            $size += repository_get_directory_size($fullfile, $excludefile);
        } else {
            $size += repository_filesize($fullfile);
        }
    }
    closedir($dir);
    return $size;
}
开发者ID:NextEinstein,项目名称:riverhills,代码行数:30,代码来源:repository.php

示例7: module_do_gui

 /**
  * The main user interface for the file dump.
  *
  * @return tempcode	The UI.
  */
 function module_do_gui()
 {
     $title = get_page_title('FILE_DUMP');
     $place = filter_naughty(get_param('place', '/'));
     if (substr($place, -1, 1) != '/') {
         $place .= '/';
     }
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=filedump&filter=' . $place;
     // Show tree
     $dirs = explode('/', substr($place, 0, strlen($place) - 1));
     $i = 0;
     $pre = '';
     $file_tree = new ocp_tempcode();
     while (array_key_exists($i, $dirs)) {
         if ($i > 0) {
             $d = $dirs[$i];
         } else {
             $d = do_lang('FILE_DUMP');
         }
         if (array_key_exists($i + 1, $dirs)) {
             $tree_url = build_url(array('page' => '_SELF', 'place' => $pre . $dirs[$i] . '/'), '_SELF');
             if (!$file_tree->is_empty()) {
                 $file_tree->attach(do_template('BREADCRUMB', array('_GUID' => '7ee62e230d53344a7d9667dc59be21c6')));
             }
             $file_tree->attach(hyperlink($tree_url, $d));
         }
         $pre .= $dirs[$i] . '/';
         $i++;
     }
     if (!$file_tree->is_empty()) {
         breadcrumb_add_segment($file_tree, $d);
     } else {
         breadcrumb_set_self($i == 1 ? do_lang_tempcode('FILE_DUMP') : make_string_tempcode(escape_html($d)));
     }
     // Check directory exists
     $fullpath = get_custom_file_base() . '/uploads/filedump' . $place;
     if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place)) {
         if (has_specific_permission(get_member(), 'upload_filedump')) {
             @mkdir($fullpath, 0777) or warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY', escape_html($fullpath), escape_html(dirname($fullpath))));
             fix_permissions($fullpath, 0777);
             sync_file($fullpath);
         }
     }
     // Find all files in the incoming directory
     $handle = opendir(get_custom_file_base() . '/uploads/filedump' . $place);
     $i = 0;
     $filename = array();
     $description = array();
     $filesize = array();
     $filetime = array();
     $directory = array();
     $deletable = array();
     while (false !== ($file = readdir($handle))) {
         if (!should_ignore_file('uploads/filedump' . $place . $file, IGNORE_ACCESS_CONTROLLERS | IGNORE_HIDDEN_FILES)) {
             $directory[$i] = !is_file(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             $filename[$i] = $directory[$i] ? $file . '/' : $file;
             if ($directory[$i]) {
                 $filesize[$i] = do_lang_tempcode('NA_EM');
             }
             $dbrows = $GLOBALS['SITE_DB']->query_select('filedump', array('description', 'the_member'), array('name' => $file, 'path' => $place));
             if (!array_key_exists(0, $dbrows)) {
                 $description[$i] = $directory[$i] ? do_lang_tempcode('NA_EM') : do_lang_tempcode('NONE_EM');
             } else {
                 $description[$i] = make_string_tempcode(escape_html(get_translated_text($dbrows[0]['description'])));
             }
             if ($description[$i]->is_empty()) {
                 $description[$i] = do_lang_tempcode('NONE_EM');
             }
             $deletable[$i] = array_key_exists(0, $dbrows) && $dbrows[0]['the_member'] == get_member() || has_specific_permission(get_member(), 'delete_anything_filedump');
             if ($directory[$i]) {
                 $size = get_directory_size(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = NULL;
             } else {
                 $size = filesize(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = filemtime(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             }
             $filesize[$i] = clean_file_size($size);
             $filetime[$i] = is_null($timestamp) ? NULL : get_timezoned_date($timestamp);
             $i++;
         }
     }
     closedir($handle);
     if ($i != 0) {
         require_code('templates_table_table');
         $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS')));
         $rows = new ocp_tempcode();
         for ($a = 0; $a < $i; $a++) {
             if ($directory[$a]) {
                 $link = build_url(array('page' => '_SELF', 'place' => $place . $filename[$a]), '_SELF');
             } else {
                 $link = make_string_tempcode(get_custom_base_url() . '/uploads/filedump' . str_replace('%2F', '/', rawurlencode($place . $filename[$a])));
             }
             if (!$directory[$a]) {
                 if ($deletable[$a]) {
                     $delete_url = build_url(array('page' => '_SELF', 'type' => 'ed', 'file' => $filename[$a], 'place' => $place), '_SELF');
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:filedump.php

示例8: array

 $table->head = array($hdrid, $hdrname, $hdrsize);
 $table->size = array('*', '*', '*');
 $table->align = array('right', 'left', 'right');
 $table->width = '80%';
 $table->data = array();
 $table->tablealign = 'center';
 $table->rowclass = array();
 $data = array();
 $total = 0;
 foreach ($courses as $c) {
     if ($c->id == SITEID) {
         $c->fullname .= ' (' . $strsite . ')';
     } elseif ($cat) {
         $c->fullname .= ' (' . $c->name . ')';
     }
     $duraw = get_directory_size($CFG->dataroot . '/' . $c->id);
     $total += $duraw;
     $du = display_size($duraw);
     $courselink = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '">' . $c->fullname . '</a>';
     $data[] = array($c->id, $courselink, $duraw);
     $table->rowclass[] = 'coursesize_data';
 }
 /// Sort the data by size if required
 if ($sort == 'size_ASC') {
     usort($data, 'coursesize_sort_by_size_asc');
 } elseif ($sort == 'size_DESC') {
     usort($data, 'coursesize_sort_by_size_desc');
 }
 /// Now we need to make the sizes human readable
 /// We can't do this earlier because the size sort won't work
 foreach ($data as $row) {
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:index.php

示例9: get_directory_size

/**
 * Get Directory Size - get_video_file($vdata,$no_video,false);
 */
function get_directory_size($path)
{
    $totalsize = 0;
    $totalcount = 0;
    $dircount = 0;
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            $nextpath = $path . '/' . $file;
            if ($file != '.' && $file != '..' && !is_link($nextpath)) {
                if (is_dir($nextpath)) {
                    $dircount++;
                    $result = get_directory_size($nextpath);
                    $totalsize += $result['size'];
                    $totalcount += $result['count'];
                    $dircount += $result['dircount'];
                } elseif (is_file($nextpath)) {
                    $totalsize += filesize($nextpath);
                    $totalcount++;
                }
            }
        }
    }
    closedir($handle);
    $total['size'] = $totalsize;
    $total['count'] = $totalcount;
    $total['dircount'] = $dircount;
    return $total;
}
开发者ID:yukisky,项目名称:clipbucket,代码行数:31,代码来源:functions.php

示例10: get_directory_size

/**
 * Adds up all the files in a directory and works out the size.
 *
 * @param string $rootdir  ?
 * @param string $excludefile  ?
 * @return array
 * @todo Finish documenting this function
 */
function get_directory_size($rootdir, $excludefile = '')
{
    global $CFG;
    $textlib = textlib_get_instance();
    // do it this way if we can, it's much faster
    if (!empty($CFG->pathtodu) && is_executable(trim($CFG->pathtodu))) {
        $command = trim($CFG->pathtodu) . ' -sk --apparent-size ' . escapeshellarg($rootdir);
        exec($command, $output, $return);
        if (is_array($output)) {
            return get_real_size(intval($output[0]) . 'k');
            // we told it to return k.
        }
    }
    $size = 0;
    if (!is_dir($rootdir)) {
        // Must be a directory
        return $dirs;
    }
    if (!($dir = @opendir($rootdir))) {
        // Can't open it for some reason
        return $dirs;
    }
    while (false !== ($file = readdir($dir))) {
        $firstchar = $textlib->substr($file, 0, 1);
        if ($firstchar == '.' or $file == 'CVS' or $file == $excludefile) {
            continue;
        }
        $fullfile = $rootdir . '/' . $file;
        if (filetype($fullfile) == 'dir') {
            $size += get_directory_size($fullfile, $excludefile);
        } else {
            $size += filesize($fullfile);
        }
    }
    closedir($dir);
    return $size;
}
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:45,代码来源:elgglib.php

示例11: displaydir


//.........这里部分代码省略.........
                $prop->style = "white-space: nowrap;";
                $prop->align = "center";
                $prop->classtr = "folder";
                wiki_change_row($prop);
                echo '&nbsp;';
                $prop = null;
                $prop->class = 'name';
                $prop->align = 'left';
                $prop->style = "white-space: nowrap;";
                wiki_change_column($prop);
                $prop = null;
                $prop->src = $CFG->pixpath . '/f/parent.gif';
                $prop->height = "16";
                $prop->width = "16";
                $prop->alt = get_string('parentfolder');
                $out = wiki_img($prop, true);
                $prop = null;
                $prop->href = 'index.php?id=' . $id . '&amp;wdir=' . $fileurl;
                wiki_a($out, $prop);
                $prop = null;
                $prop->href = 'index.php?id=' . $id . '&amp;wdir=' . $fileurl;
                wiki_a(get_string('parentfolder'), $prop);
                wiki_change_column();
                echo '&nbsp;';
                wiki_change_column();
                echo '&nbsp;';
                wiki_change_column();
                echo '&nbsp;';
            } else {
                $count++;
                $filename = $fullpath . "/" . $dir;
                $fileurl = rawurlencode($wdir . "/" . $dir);
                $filesafe = rawurlencode($dir);
                $filesize = display_size(get_directory_size("{$fullpath}/{$dir}"));
                $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
                $prop->align = "center";
                $prop->style = "white-space: nowrap;";
                $prop->class = "checkbox";
                $prop->classtr = "folder";
                wiki_change_row($prop);
                $prop = null;
                $prop->name = 'file' . $count;
                $prop->value = $fileurl;
                wiki_input_checkbox($prop);
                $prop = null;
                $prop->class = 'name';
                $prop->align = "left";
                $prop->style = "white-space: nowrap;";
                wiki_change_column($prop);
                $prop = null;
                $prop->src = $CFG->pixpath . '/f/folder.gif';
                $prop->height = "16";
                $prop->width = "16";
                $prop->alt = "Folder";
                $out = wiki_img($prop, true);
                $prop = null;
                $prop->href = 'index.php?id=' . $id . '&amp;wdir=' . $fileurl . '&amp;choose=' . $choose;
                wiki_a($out, $prop);
                $prop = null;
                $prop->href = 'index.php?id=' . $id . '&amp;wdir=' . $fileurl . '&amp;choose=' . $choose;
                wiki_a(htmlspecialchars($dir), $prop);
                $prop = null;
                $prop->class = 'size';
                $prop->align = "right";
                $prop->style = "white-space: nowrap;";
                wiki_change_column($prop);
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:67,代码来源:index.php

示例12: mimeinfo

        } else {
            $icon = mimeinfo("icon", $file);
            echo "<img src=\"{$CFG->pixpath}/f/{$icon}\"  height=\"16\" width=\"16\" alt=\"\" /> {$file}<br />";
        }
    }
}
function print_cell($alignment = 'center', $text = '&nbsp;', $class = '')
{
    if ($class) {
        $class = ' class="' . $class . '"';
    }
    echo '<td align="' . $alignment . '" nowrap="nowrap"' . $class . '>' . $text . '</td>';
}
function displaydir($wdir)
{
    //  $wdir == / or /a or /a/b/c/d  etc
    global $basedir;
    global $podcast;
    global $id;
    global $USER, $CFG;
    global $choose;
    $fullpath = $basedir . $wdir;
    $dirlist = array();
    $directory = opendir($fullpath);
    // Find all files
    while (false !== ($file = readdir($directory))) {
        if ($file == "." || $file == "..") {
            continue;
        }
        if (is_dir($fullpath . "/" . $file)) {
            $dirlist[] = $file;
        } else {
            $filelist[] = $file;
        }
    }
    closedir($directory);
    $strname = get_string("name");
    $strsize = get_string("size");
    $strmodified = get_string("modified");
    $straction = get_string("action");
    $strmakeafolder = get_string("makeafolder");
    $struploadafile = get_string("uploadafile");
    $strselectall = get_string("selectall");
    $strselectnone = get_string("deselectall");
    $strwithchosenfiles = get_string("withchosenfiles");
    $strmovetoanotherfolder = get_string("movetoanotherfolder");
    $strmovefilestohere = get_string("movefilestohere");
    $strdeletecompletely = get_string("deletecompletely");
    $strcreateziparchive = get_string("createziparchive");
    $strrename = get_string("rename");
    $stredit = get_string("edit");
    $strunzip = get_string("unzip");
    $strlist = get_string("list");
    $strrestore = get_string("restore");
    $strchoose = get_string("choose");
    echo "<form action=\"index.php\" method=\"post\" name=\"dirform\">";
    echo '<input type="hidden" name="choose" value="' . $choose . '" />';
    echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />";
    echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\" class=\"files\">";
    echo "<tr>";
    echo "<th width=\"5\"></th>";
    echo "<th align=\"left\" class=\"header name\">{$strname}</th>";
    echo "<th align=\"right\" class=\"header size\">{$strsize}</th>";
    echo "<th align=\"right\" class=\"header date\">{$strmodified}</th>";
    echo "<th align=\"right\" class=\"header commands\">{$straction}</th>";
    echo "</tr>\n";
    if ($wdir != "/") {
        $dirlist[] = '..';
    }
    $count = 0;
    if (!empty($dirlist)) {
        asort($dirlist);
        foreach ($dirlist as $dir) {
            echo "<tr class=\"folder\">";
            if ($dir == '..') {
                $fileurl = rawurlencode(dirname($wdir));
                print_cell();
                print_cell('left', '<a href="index.php?id=' . $id . '&amp;pod=' . $podcast . '&amp;wdir=' . $fileurl . '&amp;choose=' . $choose . '"><img src="' . $CFG->pixpath . '/f/parent.gif" height="16" width="16" alt="' . get_string('parentfolder') . '" /></a> <a href="index.php?id=' . $id . '&amp;pod=' . $podcast . '&amp;wdir=' . $fileurl . '&amp;choose=' . $choose . '">' . get_string('parentfolder') . '</a>', 'name');
                print_cell();
                print_cell();
                print_cell();
            } else {
                $count++;
                $filename = $fullpath . "/" . $dir;
                $fileurl = rawurlencode($wdir . "/" . $dir);
                $filesafe = rawurlencode($dir);
                $filesize = display_size(get_directory_size("{$fullpath}/{$dir}"));
                $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
                print_cell("center", "<input type=\"checkbox\" name=\"file{$count}\" value=\"{$fileurl}\" />", 'checkbox');
                print_cell("left", "<a href=\"index.php?id={$id}&amp;pod={$podcast}&amp;wdir={$fileurl}&amp;choose={$choose}\"><img src=\"{$CFG->pixpath}/f/folder.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"Folder\" /></a> <a href=\"index.php?id={$id}&amp;pod={$podcast}&amp;wdir={$fileurl}&amp;choose={$choose}\">" . htmlspecialchars($dir) . "</a>", 'name');
                print_cell("right", $filesize, 'size');
                print_cell("right", $filedate, 'date');
                print_cell("right", "<a href=\"index.php?id={$id}&amp;pod={$podcast}&amp;wdir={$wdir}&amp;file={$filesafe}&amp;action=rename&amp;choose={$choose}\">{$strrename}</a>", 'commands');
            }
            echo "</tr>";
        }
    }
    if (!empty($filelist)) {
        asort($filelist);
        foreach ($filelist as $file) {
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:index.php

示例13: define

$userquery->admin_login_check();
$userquery->login_check('web_config_access');
/* Assigning page and subpage */
if (!defined('MAIN_PAGE')) {
    define('MAIN_PAGE', 'Stats And Configurations');
}
if (!defined('SUB_PAGE')) {
    define('SUB_PAGE', 'Reports &amp; Stats');
}
$vid_dir = get_directory_size(VIDEOS_DIR);
$thumb_dir = get_directory_size(THUMBS_DIR);
$orig_dir = get_directory_size(ORIGINAL_DIR);
$user_thumbs = get_directory_size(USER_THUMBS_DIR);
$user_bg = get_directory_size(USER_BG_DIR);
$grp_thumbs = get_directory_size(GP_THUMB_DIR);
$cat_thumbs = get_directory_size(CAT_THUMB_DIR);
assign('vid_dir', $vid_dir);
assign('thumb_dir', $thumb_dir);
assign('orig_dir', $orig_dir);
assign('user_thumbs', $user_thumbs);
assign('user_bg', $user_bg);
assign('grp_thumbs', $grp_thumbs);
assign('cat_thumbs', $cat_thumbs);
if (!defined('MAIN_PAGE')) {
    define('MAIN_PAGE', 'Stats And Configurations');
}
if (!defined('SUB_PAGE')) {
    if ($_GET['view'] == 'search') {
        define('SUB_PAGE', 'Search Members');
    } else {
        define('SUB_PAGE', 'Reports & Stats');
开发者ID:Coding110,项目名称:cbvideo,代码行数:31,代码来源:reports.php

示例14: check_shared_space_usage

/**
 * Check disk space usage against page view ratio for shared hosting.
 *
 * @param  integer		The extra space in bytes requested
 */
function check_shared_space_usage($extra)
{
    global $SITE_INFO;
    if (array_key_exists('throttle_space_registered', $SITE_INFO)) {
        $views_till_now = intval(get_value('page_views'));
        $bandwidth_allowed = $SITE_INFO['throttle_space_registered'];
        $total_space = get_directory_size(get_custom_file_base() . '/uploads');
        if ($bandwidth_allowed * 1024 * 1024 >= $total_space + $extra) {
            return;
        }
    }
    if (array_key_exists('throttle_space_complementary', $SITE_INFO)) {
        //		$timestamp_start=$SITE_INFO['custom_user_'].current_share_user();
        //		$days_till_now=(time()-$timestamp_start)/(24*60*60);
        $views_till_now = intval(get_value('page_views'));
        $space_allowed = $SITE_INFO['throttle_space_complementary'] + $SITE_INFO['throttle_space_views_per_meg'] * $views_till_now;
        $total_space = get_directory_size(get_custom_file_base() . '/uploads');
        if ($space_allowed * 1024 * 1024 < $total_space + $extra) {
            critical_error('RELAY', 'The hosted user has exceeded their shared-hosting "disk-space to page-view" ratio. More pages must be viewed before this may be uploaded.');
        }
    }
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:27,代码来源:files2.php

示例15: display_size

 }
 // we know it's a directory now, but lets ignore non-numeric directories as course data is stored in moodledata in a directory named after its course id
 if (!is_numeric($file)) {
     // site files are stored in /moodledata/$courseid where $courseid is a number - we want to filter out nonsite related directories
     continue;
 }
 if (is_dir("{$path}/backupdata")) {
     $bdata = display_size(get_directory_size("{$path}/backupdata"));
     $bdatatotal += (int) get_directory_size("{$path}/backupdata");
 } else {
     $bdata = display_size((int) 0);
     $bdatatotal += (int) 0;
 }
 if (is_dir($path)) {
     $sdata = display_size(get_directory_size($path));
     $sdatatotal += (int) get_directory_size($path);
 } else {
     $sdata = display_size((int) 0);
     $sdatatotal += (int) 0;
 }
 $instructors = get_records_sql("select userid from {$CFG->prefix}role_assignments where roleid=3 and contextid=(select id from {$CFG->prefix}context where contextlevel=50 and instanceid={$file})");
 if (!empty($instructors)) {
     $catid = get_record("course", "id", $file);
     // $file is course id
     $category = get_record("course_categories", "id", $catid->category);
     $parentcategory = null;
     if (isset($category->parent) && $category->parent !== "0") {
         $parentcategory = get_record("course_categories", "id", $category->parent);
     }
     foreach ($instructors as $instructor) {
         $userdetail = get_record_sql("select firstname, lastname, email from {$CFG->prefix}user where id={$instructor->userid}");
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:index.php


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