The MU forums have moved to WordPress.org

Space limitations and others hacks (22 posts)

  1. lissyx
    Inactive
    Posted 18 years ago #

    As we want to use WordPressµ for making a big service, we'll have to put some limitations, such as space quotas, and limitations on the max file size upload that can be set.

    For now, i'm using a ugly hack, which consists in 3 files. One, called 'idn-limits.inc.php' which handle hard limitations about max file size to set and others like paths (you know, in the 'Options', then 'Others' menus), in order nobody to override them.

    The two other are idn-space.php and space.inc.php which both hande for quotas. The first is a GUI to manage files uploaded (simple manage, which mean you can only see files uploaded, have a link for them, and delete them). The second contains some functions to calculate freespace, used space, and see if the quotas is full or not. This is simple but pretty robust code, even if it's a ugly (and in french !) hack.

    As plugins can be (de)activated by users, i dunno if it's secure to make a plugin for this code.

    So, as we're using WordPressµ, i'm thinking it's a morale way to act by giving some stuff which i've done and that could interest people.

    Is there people interested here by this hack, then i could prepare the code and give it to you, with some doc to use it.

    Hope you'll be interested !

  2. NetAndif
    Inactive
    Posted 18 years ago #

    Hi lissyx

    As there are several functions and plugins which let the users upload or generate files, we may really get into troubles if having no quotas.
    In the latest wpmu snapshot, unfortunately the file upload space limiting option is disabled. I will have to find out, why.

    But i'm also very interested in taking a look at your code.
    Maybe it would be a way for including quotas...

    Thanks,
    NetAndif
    netandif at cornblogs dot com

  3. lissyx
    Inactive
    Posted 18 years ago #

    My code is a hack on wpmu from february 23rd's snapshot.

    wait some minute, i'll publish hack and diff off wp-admin needed :)

  4. lissyx
    Inactive
    Posted 18 years ago #

    i have to add that for me space limitation is only for uploaded files, not generated ones.

  5. NetAndif
    Inactive
    Posted 18 years ago #

    For uploaded files is ok, i was only thinking a step forward already...
    What about your file management gui? Is this a plugin?

  6. lissyx
    Inactive
    Posted 18 years ago #

    No, but i think it could be done by a plugin, but i dunno how to create one :)

    Code is ready, i'm cleaning the diff from all translation stuff.

  7. lissyx
    Inactive
    Posted 18 years ago #

    So, here we go. Code and diff is available. A special ntoe about diff is that it was also containing some translation stuff (i wasn't able to translate without hacking until i found that i was just needing a languages/fr_FR.mo file :)), so you'll probably have to check the diff yourself to find what to do, but's it's really easy (some HTML to comment, some includes to add and one or two functions to call ...)

    If you can't get it working, just tell me :)

    http://dev.infos-du-net.com/~lissyx/blogs/

    And btw, have you some docs on creating plugins ? As what you said makes me thinking it would be a good plugin, and that it could be very powerful (mode file control, such as renaming, creating/deleting directory and others :) )

  8. NetAndif
    Inactive
    Posted 18 years ago #

    thanks very much lissyx, i will look at the code soon, and then post my thoughts

    for the plugin how-to: i could make one, or even post the required steps
    but allow for a little delay for all this, as i'm actually working on another issue...

  9. lissyx
    Inactive
    Posted 18 years ago #

    Sure, take your time :)

  10. NetAndif
    Inactive
    Posted 18 years ago #

    just a maybe little silly question:
    how can i get the files from this folder?

  11. lissyx
    Inactive
    Posted 18 years ago #

    oh, yes, i've forgot, you need some stuff for the .htaccess !

    just 2sec i'm posting it on the web !

    Here : http://dev.infos-du-net.com/~lissyx/blogs/for-htaccess.txt

  12. NetAndif
    Inactive
    Posted 18 years ago #

    please, could you make an archive of all the file and post it to my email?

  13. lissyx
    Inactive
    Posted 18 years ago #

    Just gimme your email so!

  14. NetAndif
    Inactive
    Posted 18 years ago #

    didn't look above? ;-)

    netandif at cornblogs dot com

    I'm out now for a while
    Will be back later...
    Thanks for contributing your code!

    NetAndif

  15. lissyx
    Inactive
    Posted 18 years ago #

    i'm sorry, i havn't so your email anywhere ...

    email is near to go out :) and i've tested the 'hack' on a non-hacked wp-admin/ dir, it works (didn't try by applying the diff so ... )

    Edit: mail is delivered :)

  16. lissyx
    Inactive
    Posted 18 years ago #

    I started some code, but which features are to be need ?

    For now, it can lists files, and delete some files. Space counter will be added in a few !

  17. quikfire
    Inactive
    Posted 18 years ago #

    Even though the space limit option disabled in the admin console in the latest MU snapshot, I found that editing wp-inst/wp-includes/wpmu-functions.php works too.

    Just search for somewhere line 186:
    $spaceAllowed = wpmu_adminOption_get("wpmu_space_allocated", 10485760 );

    10485760 indicates 10 MBs, and can simply be modified to limit users' space (1MB = 1024KB)

  18. lissyx
    Inactive
    Posted 18 years ago #

    Oh thanks !

    Ehe it's only for recent snapshot, our doesn't have this option ...

  19. capx
    Inactive
    Posted 18 years ago #

    Hi, about the space limitation, i think its best to put percentage also. Here's a simple code i add for it (change in wpmu-functions.php):

    (<?php print round((($spaceAllowed-$size)*100/$spaceAllowed), 2);?>%)

    Hope this helps

  20. lissyx
    Inactive
    Posted 18 years ago #

    I personnaly prefer the real size ;)

  21. lissyx
    Inactive
    Posted 18 years ago #

    Hmm, I would like to know if some people here have a solution to compute used space in a directory when running PHP with Safe mode restrictions ... (and so, doing a du -hs isn't possible)

  22. lissyx
    Inactive
    Posted 18 years ago #

    btw, I've just nearly finished one project around mozilla, and will have some time for finishing File management plugins.

    Does the plugin interface changed from release around february ?
    Which feature would you like to be included ?

About this Topic