The MU forums have moved to WordPress.org

Check space available (11 posts)

  1. mypatricks
    Member
    Posted 17 years ago #

    Hi, How do I display the space available on dashboard? any suggest? Thanks

  2. drmike
    Member
    Posted 17 years ago #

    Search? :)

    I'm assuming pictures. You may want to review the other threads covering this as it's been discussed in the past.

  3. samchng
    Member
    Posted 17 years ago #

    See line 32 in wpmu-functions.php. Might help cause I see

    function wpmu_checkAvailableSpace($action) {

  4. mypatricks
    Member
    Posted 17 years ago #

    Thanks all!, I create a plugin files:

    <?php
    function space_limit() {
    global $wpblog, $blog_id;

    $spaceAllowed = get_site_option("blog_upload_space" );
    if( $spaceAllowed == false )
    $spaceAllowed = 10;

    $dirName = ABSPATH."wp-content/blogs.dir/".$blog_id."/files/";

    $dir = dir($dirName);
    $size = 0;

    while($file = $dir->read()) {
    if ($file != '.' && $file != '..') {
    if (is_dir($file)) {
    $size += dirsize($dirName . '/' . $file);
    } else {
    $size += filesize($dirName . '/' . $file);
    }
    }
    }
    $dir->close();
    $size = $size / 1024 / 1024;

    ?>
    Upload Space Available : <?php printf( "%2.2f", ( ($spaceAllowed-$size) ) ) ?>MB
    <img src="/wp-admin/images/space.gif" height="10px" width="<?php printf( "%2.2f", ( ($spaceAllowed-$size)*10 ) ) ?>%">
    <?php

    }

    ?>

    and insert this code:
    <?php space_limit();?>

  5. drmike
    Member
    Posted 17 years ago #

    Cool.

    Is it worth submitting this as a patch to the Trac? This would probably be a welcomed addition to the code.

  6. samchng
    Member
    Posted 17 years ago #

    Tried testing it, got this on home.php. A clash with the other plugin. I uploaded spaceallowed.php into mu-plugins. Haven't even called it yet and I get this error. Any ideas Patrick?

    Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/bizblogo/public_html/wpmu/wp-inst/wp-content/mu-plugins/spaceallowed.php:36) in /home/bizblogo/public_html/wpmu/wp-inst/wp-content/mu-plugins/wp-hashcash.php on line 29

    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/bizblogo/public_html/wpmu/wp-inst/wp-content/mu-plugins/spaceallowed.php:36) in /home/bizblogo/public_html/wpmu/wp-inst/wp-content/mu-plugins/wp-hashcash.php on line 29

  7. mypatricks
    Member
    Posted 17 years ago #

    You must put this code <?php space_limit();?> into Admin Panel. Not home.php.

  8. samchng
    Member
    Posted 17 years ago #

    Even before I add that into my admin panel, I have this error on my home.php. Hmm...

  9. amanzi
    Member
    Posted 17 years ago #

    Make sure that you don't have any blank lines or spaces after the ?> command at the end of the file.

  10. samchng
    Member
    Posted 17 years ago #

    Ok, we'll give it a try again. Thanks! :)

  11. drmike
    Member
    Posted 17 years ago #

    Hmm, I finally got around to trying this plugin and, from sticking in some echos into various points, it looks like it's going as far as the top subdirectory (ie '2006'), getting the size read off of that (ie 512) and reporting that. It's not finding the pictures within the subdirctories.

    edit: If I point the $dirName line to an actual subdirectory with files, (ie files/2006/07) it works fine. Adds them up and all that. It's just not stepping through the subdirectories.

About this Topic

  • Started 17 years ago by mypatricks
  • Latest reply from drmike